in reply to Re: Match a pattern only if it is not within another pattern
in thread Match a pattern only if it is not within another pattern
(bar.+?qux)|(foo) # capture anything with 'bar' and 'foo' as # bookends in $1 OR # all other 'foo' in $2 defined $2 ? '123' : $1 # if $2 exists, replace it with 123 # otherwise replace $1 back into # the string ]ge # eval globally
Thanks. I am glad to see this was beyond my league without your help.
Update: BrowserUK, how on earth do you even begin to think this twisted? I can't fathom how to "practice" regexp matching other than answering questions from novices such as myself. I have been scanning Friedl's book, but I guess nothing substitutes for practice at ever increasing levels of complexity, much like a video game. Well, thanks for getting me over this particular hump for now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Match a pattern only if it is not within another pattern
by hv (Prior) on Aug 16, 2005 at 23:07 UTC | |
|
Re^3: Match a pattern only if it is not within another pattern
by ysth (Canon) on Aug 16, 2005 at 19:53 UTC | |
by Transient (Hermit) on Aug 16, 2005 at 19:56 UTC | |
by xdg (Monsignor) on Aug 16, 2005 at 20:04 UTC |