Not so simple. You have also to anchor the left hand end:
s/^.*?TEST/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.
In reply to Re^2: How do you make a regex non greedy
by GrandFather
in thread How do you make a regex non greedy
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |