Re: Regexps from shell wildcards

macrakis@osf.org (Stavros Macrakis)
Mon, 5 Apr 1993 16:39:07 GMT

          From comp.compilers

Related articles
Regexps from shell wilcards colas@opossum.inria.fr (1993-04-02)
Re: Regexps from shell wildcards imp@Boulder.ParcPlace.COM (Warner Losh) (1993-04-05)
Re: Regexps from shell wildcards kanze@us-es.sel.de (1993-04-05)
Re: Regexps from shell wildcards macrakis@osf.org (1993-04-05)
Re: Regexps from shell wildcards gnb@leo.bby.com.au (1993-04-06)
| List of all articles for this month |

Newsgroups: comp.compilers
From: macrakis@osf.org (Stavros Macrakis)
Keywords: lex
Organization: OSF Research Institute
References: 93-04-012 93-04-018
Date: Mon, 5 Apr 1993 16:39:07 GMT

colas@opossum.inria.fr (Colas Nahaboo) asks for an algorithm to convert
shell-expressions into regular expressions.


Warner Losh <imp@Boulder.ParcPlace.COM> answers:


      Just change '*' to '.*' and quote all the meta characters...


You also need to "anchor" the beginning and end with "^" and "$", since
shell patterns must match the whole filename, and Unix regular expressions
match any substring.


      ...to do /bin/csh shell expressions, then you'll find that things like
      "*.{c,C,H,h,cf}" cause problems and cause the output string length
      to grow wildly.


"^.*\.(c|C|H|h|cf)$" causes no problems. Of course, this requires
full regular expressions (egrep, emacs), not brain-dead subsets (grep,
ex).


-s
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.