in reply to Re: How do you make a regex non greedy
in thread How do you make a regex non greedy
Not so simple. You have also to anchor the left hand end:
s/^.*?(?=TEST)//
Update: Argh - one day I'll stop getting bitten by that! Anonymous Monk is quite right. No backtracking is required to get a match so .*? matches everything from the start or the string up to TEST - no anchor needed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do you make a regex non greedy
by Anonymous Monk on Mar 20, 2011 at 05:05 UTC |