Regular expression to validate open tags

I am having problems creating a Regex that will return tags that are not self-closing. So I would like it to return tags that are like:

<blah>

      

But not tags that are similar:

<blah/>

      

I have the following regex:

<(o|p)(.*?)>

      

Which is a little oversimplified, ignore the rest of what he does, what he should do despite this oddity. This will match all tags, although I need one that will ignore matches where the tag is self-closing.

Greetings

0


a source to share


1 answer


Try this regex:

<(?:o|p)(?:[^"'>/]+|"[^"]*"|'[^']*')*>

      



XHTML syntax is assumed.

+1


a source







All Articles