[comp.sys.amiga.tech] Regular expressions vs. file name generation

" Seaman) (06/09/90)

daveh@cbmvax.commodore.com (Dave Haynie) writes:
< As pointed out many times here before, the Amiga regular expression language
< is far more powerful than the other models available at the time.  Now you're
< really the one talking syntactic sugar.  Sure, "*" could be substituted for
< "#?", but what do you substitute for FILE#(A|B|C#E??).(C|O), or a similar 
                                       ^^^^^^^^^^^^^^^^^^^^^^
< AmigaDOS pattern?  The only thing that comes close is the grep language,
< which isn't used for file naming, but that has the disadvantage of using a
< number of common file characters, such as ".", as part of its regular 
< expression language.  I would be annoyed if I had to type "more thing\.c"...

While I don't want to sound critical (I LIKE the regular expression syntax
on the Amiga!), I feel that SOME of the more intelligent UNIX shells have
been slightly slighted (?).  Although the Bourne shell could not match the
power of the above statement, csh and ksh can.  I would implement it
in csh as follows:

    ls file{[ab],c{e*,}??}.[co]

and in ksh:

    ls file*([ab]|c*(e)??).[co]

These may be somewhat more cryptic than the Amiga equivalent, but they
are possible (I just tried both, and both retrieved the expected file
names).

-- 
Chris (Insert phrase here) Seaman |    ___-/^\-___
cseaman@sequent <or>              |  //__--\O/--__\\    nI' yIyIn 'ej yIchep.
...!uunet!sequent!cseaman         | //             \\
The Home of the Killer Smiley     | `\             /'

peter@sugar.hackercorp.com (Peter da Silva) (06/10/90)

In article <36467@sequent.UUCP> cseaman@sequent.UUCP (Chris "I'm Outta Here, Man!" Seaman) writes:
> Although the Bourne shell could not match the
> power of the above statement, csh and ksh can.  I would implement it
> in csh as follows:

>     ls file{[ab],c{e*,}??}.[co]

Fine. How about "All files matching a legal C format statement?"

%(|(|-)(*|#(0|1|2|3|4|5|6|7|8|9)))(|.(*|#(0|1|2|3|4|5|6|7|8|9)))(|l)(d|f|o|g|x|c)

(more or less).
-- 
 _--_|\  Peter da Silva <peter@sugar.hackercorp.com>.
/      \
\_.--._/ My other car is a hot-air balloon.
      v  "Have you hugged your wolf today?" `-_-'

jesup@cbmvax.commodore.com (Randell Jesup) (06/10/90)

In article <5806@sugar.hackercorp.com> peter@sugar.hackercorp.com (Peter da Silva) writes:
>Fine. How about "All files matching a legal C format statement?"
>
>%(|(|-)(*|#(0|1|2|3|4|5|6|7|8|9)))(|.(*|#(0|1|2|3|4|5|6|7|8|9)))(|l)(d|f|o|g|x|c)

	You could make that a lot smaller using the 2.0 character classes...
( [0-9], etc.)

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"

peter@sugar.hackercorp.com (Peter da Silva) (06/10/90)

In article <12518@cbmvax.commodore.com> jesup@cbmvax (Randell Jesup) writes:
> 	You could make that a lot smaller using the 2.0 character classes...
> ( [0-9], etc.)

I wasn't aware that this was comp.sys.amiga.tech.2.0. Hardly anyone has 2.0.
A few of us have 1.4 beta. You can't even assume that everyone has 1.3. On
occasion I have had to kick up 1.1 to run old software (luckily, I never had
to deal with 1.0 or .98).
-- 
 _--_|\  Peter da Silva <peter@sugar.hackercorp.com>.
/      \
\_.--._/ My other car is a hot-air balloon.
      v  "Have you hugged your wolf today?" `-_-'

mwm@raven.pa.dec.com (Mike (Real Amigas have keyboard garages) Meyer) (06/17/90)

In article <36467@sequent.UUCP> cseaman@sequent.UUCP (Chris "I'm Outta Here, Man!" Seaman) writes:
   daveh@cbmvax.commodore.com (Dave Haynie) writes:
   < As pointed out many times here before, the Amiga regular expression language
   < is far more powerful than the other models available at the time.  Now you're
   < really the one talking syntactic sugar.  Sure, "*" could be substituted for
   < "#?", but what do you substitute for FILE#(A|B|C#E??).(C|O), or a similar 

   While I don't want to sound critical (I LIKE the regular expression syntax
   on the Amiga!), I feel that SOME of the more intelligent UNIX shells have
   been slightly slighted (?).  Although the Bourne shell could not match the
   power of the above statement, csh and ksh can.  I would implement it
   in csh as follows:

       ls file{[ab],c{e*,}??}.[co]

Sorry, that doesn't quite cut it. Dave's pattern will match fileaa.c,
but that won't. The c{e*,}?? is also broken.

       ls file*([ab]|c*(e)??).[co]

This one works - because ksh has extended it's pattern matching
language to look more like real regular expressions (but the operator
on subexpressions is still on the wrong end of the subexpression!).

BTW, I hadn't realized that ksh had been so extended. Thanks for
pointing it out.

	<mike



--
He was your reason for living				Mike Meyer
So you once said					mwm@relay.pa.dec.com
Now your reason for living				decwrl!mwm
Has left you half dead