Re: Regexps from shell wildcards

Warner Losh <imp@Boulder.ParcPlace.COM>
Mon, 5 Apr 1993 00:01:56 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: Warner Losh <imp@Boulder.ParcPlace.COM>
Keywords: lex
Organization: ParcPlace Boulder
References: 93-04-012
Date: Mon, 5 Apr 1993 00:01:56 GMT

>Is there an algorithm to convert shell-expressions into regular
>expressions? (i.e. generate the string ".*[.]c" from the input "*.c")


It is fairly straightforward to do this conversion for /bin/sh. Just
change '*' to '.*' and quote all the meta characters that have no special
meaning in /bin/sh, but do in the regexp package you are using. However,
if you wanted 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.


>In the same vein, is there an algorithm to generate case-independent
>regular expressions from nomal ones? (i.e. generate the string
>"[aA][bB][cC][eEfFgG]*" from the input "abc[efg]*")


I think this also falls withing the relm of brute force algorithms. Since
there are only two states (inside and outside of square brackets), a
single pass through the string, copying to a dest string should do the
trick.


Warner
--


Post a followup to this message

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