Jump to content

Regex wizards - matching same number of opening and closing tags


frizi

Recommended Posts

Hi

 

It would  be great if you could help me with my problem. I would like to use a regex expression (or a php script) that would select one complex tag. The complexity at this is that the tag could contain the same tag inside (at menu content for example - ul li ul).

 

Therefor I need a special code that would search so many closing tags as many opening tags for matching the following first UL:

 

<ul> <li> first </li>

<li> <ul>

<li> second </li>

<li> <ul> third </ul> </li> </ul> </li>

<li> <ul> <li> fourth </li> </ul> </li>

<li> end of selection </li>

</ul>

<ul> this should be not selected </ul>

 

I need to search so many opening tags as closing tags from the first tag (ul) until next different tag.

It was told me that I should use Dom document. This is not possible because I'm working with transitional style html style and I need just the first level (main) tags.

 

Thank you in forward.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.