in reply to My regex is too greedy!
I think the negated character class [^\]]+ would be a better choice (grab as many non-brackets as possible) to match everything inside the brackets without risk of flowing over into the next set of brackets. s/.+?\[\s+([^\]]+)\s+\].+/$1/; This works for me and results in 'admin'.
Also, as Mr. Muskrat demonstrates, this is not quite the right realm for a s///, you should probably be just using a match and capturing what you want.
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: My regex is too greedy!
by Nkuvu (Priest) on Mar 05, 2003 at 17:22 UTC | |
by blokhead (Monsignor) on Mar 05, 2003 at 18:07 UTC | |
by Nkuvu (Priest) on Mar 05, 2003 at 19:50 UTC |