But it also matches "TTT" in "aaaaaaaa#TTT"
That's a difference you introduced. If you put the \? back in, it won't.
/#(.*?)\?/
is equivalent to
/#([^?]*)\?/
The latter is safer. It's easy to introduced problems when using non-greedy quantifiers. They're not as resilient. For example, you can safely embed the greedy regexp in a larger regexp, but you can't safely embed the non-greedy regexp in a larger regexp.
In reply to Re^2: Regexp Confuzzelemt
by ikegami
in thread Regexp Confuzzelemt
by AntsPants
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |