Search code examples
cssregexbbedit

Regular expression remove tag after a paragraph with a given class


Is there a way to select all <br> tags that follow a paragraph with a given class? i.e. <p class="myclass">This is a paragraph</p><br>

There may be other <br> in the HTML so I cannot use this:

br {display:none;} 

and I cannot delete all <br> tags. If there is a way to select these particular <br> tags then I can use CSS.

There are about 700 pages and I do not want to go through each of them to make sure if the <br> is needed or not. I do know that it is not needed following a paragraph with the class of "myclass".

If there is no way to select these tags then I think that I can use BBEdit to do the search and replace using a regular expression. But I don't know how to write the RE that would work.

TIA, Linda


Solution

  • p.myClass+br {display:none;}
    

    This will select all <br> elements that are directly adjacent to a <p class="myClass"> element. If you need anything more dynamic than that, you will need regex.