Sublime Forum

Find only those html tags that contain other particular html tags

#1

I have some html tags starting with <p class="mb-40px"> and end with </p> The first tag has in it some other tags such as </li> </ul> </div> and spaces and \n as you can see.

<p class="mb-40px"></g></svg>               </a>
            </li>
             
        </ul>

    </div>
    </p>

    <p class="mb-40px">Foarte frumos lucru</p>
<p class="mb-40px">I love cars</p>

I want to find and delete all html tags such as the first one that contain </li> </ul> </div>

The Output should be:

    <p class="mb-40px">Foarte frumos lucru</p>
<p class="mb-40px">I love cars</p>

My solution is not good:

FIND: (?=<p class="mb-40px">)[\s\S]*?</li></div>|</ul>[\s\S]*?</p>

REPLACE BY: LEAVE EMPTY

0 Likes

#2

https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags#1732454

0 Likes

#3

for html static pages REGEX is the best solution.

0 Likes

#4

Not only is it not optimal, it isn’t a general solution at all as this very famous and heavily upvoted post makes clear.

Nevertheless I wish you good luck on. your journey

0 Likes