php - Help with regex html plus with extra string at the end -


I am trying to find HTML tags, via PHP EREG, in which {xxx} Right before the closing tag - where xxx can be [A-Za-z0- 9 _ \ -] * .

For example: & lt; P & gt; Xxxx & lt; / P & gt; & Lt; P & gt; Yyyy {asdf} & lt; / P & gt;

This is the best I can come with: /

The problem is that, it will match the 3 groups in which xxxx & lt; / P & gt; & Lt; P & gt; Yyyy , and I should only have yyyy in this situation

Hope anyone can help, Cheers, Egil

Ps. Sorry for the unnecessary title, nothing can think better.

Add a ? After each + and * in your regex, the match will be less greedy.

Negative character classes [^ {< to and [^} & lt; & Gt;]

Comments