It should be easy. Let’s say we are searching for all scripts at web page with regular expression like this:
And it will generally work… but with assumption that page contains only one script tag. In case that there is more… for example:
The result of match is:
instead of expected:
The reason is the greedy nature of .* regular expression qualifier. It matches as much text as possible.
The solution is to use non-greedy qualifier which is .*? which matches as little text as possible.
So the regular expression should look like this:
Thanks to Regular Expression HOWTO for explaining this.
Posted by Narawen Software