regex - Regexp to find only inner p tags inside the p tags -


i need find p tags inside other p tag. given below example understand better.

ex:

<p><span>test12312312312312313131</span></p> <p><span>test12</span></p>  <p>some text<p><span>test</span></p></p> 

i need regular expression find p tag inside other p tag.

in above example last p tag has p tag inside. how can find through regular expression.

if regex flavor supports lookarounds, try this:

(?s)<p>(?:(?!</?p>).)*</p>(?=(?:(?!</?p>).|<p>(?:(?!</?p>).)*</p>)*?</p>) 

this part (?:(?!</?p>).)* assures, there's no opening or closing <p within. positive lookahead @ end (?=... checks being inside </p. see demo trying @ regex101.

generally regex not means parsing html. regex did try , not work?


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -