Regex

From Andreida

non greedy

Imagine you have the following text:

<br />'Stupid ad'<br /><br />Real content<br />

If you use the regular expression

<br />'Stupid.*<br />

then you will match the complete text, not just the 'Stupid ad'. That is because '.' is greedy. If you want it to not be greedy, try:

<br />'Stupid.*?<br />

Now you should only match

<br />'Stupid ad'<br />

because you are using a non greedy search.