[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: capturing sub-expressions?

From: Linda Walsh
Subject: Re: capturing sub-expressions?
Date: Tue, 29 Jan 2008 10:20:37 -0800
User-agent: Thunderbird (Windows/20071031)

Bernd Eggink wrote:
Linda Walsh schrieb:
I keep confusing the path-matching regular expressions with
string-matching expressions and keep getting disappointed when I'm
re-reminded of the limitation...:-(

There should be no difference between path-matching and string-matching expressions. Normally even nested extended patterns work with string matching. But, in fact, !(...) appears to not work like one would expect. The only case that looked correct to me is the trivial one ${x//!(*)}, which leaves $x unchanged.

I'm not sure whether this is a bug or I (we) miss something. Interestingly, ksh behaves the same way. Can anybody clarify this?
Perhaps due to other failures, I haven't always had luck in the
with the *() !() ops due to quirk in the way they work...

Reading in the manpage, the section ordering is minorly
confusing at first glance...

Parameter Expansion
Command Substitution
Arithmetic Expansion
Process Substitution
Word Splitting
Pathname Expansion
    Pattern Matching
Quote Removal
In my copy of the man pages, Pattern matching is indented an extra
level making it look like it's under Pathname Expansion and only
applies there....but if people say it works outside of Paths...
well...must be so! :-)...darn manpages!

You are right about the !() not working as one would expect...
I thought:
    p="myswitch1 myswitch2 myswitch3"

I _hoped_ would match every thing in "p" except "myswitch2",
i.e. "myswitch1  myswitch3", which (guess I didn't think this
through too well) I wanted to leave "myswitch2" as the only
thing left in $p;  A bit too creative with my pattern matching.
Hey...whatever happened to the "Do what I want" operator???

reply via email to

[Prev in Thread] Current Thread [Next in Thread]