XTGAXX would be a valid match for /(\w\w\w)*?TGA/ The simple solution is to anchor that pattern to the start of the string:
The down side is the potential to be very slow depending on how the regex engine handles the global match./^(\w\w\w)*?TGA/g
\G forces the next match to start after the previous one, preventing any expensive backtracking.
--Greg
In reply to Re: \G and regexes
by Anonymous Monk
in thread \G and regexes
by 7stud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |