0

I need to write a regular expression for a HTML text block. What's making me sometrouble , is how to do it in a way that will check if the opening tag is the same as closing tag? What I have right now is:

"^(<b>*<i>*<u>*).*(</b>*</i>*</u>)$"

I'd also like to be able to input a text with multiple formatting (e.g. bold AND italic). Thanks in advance.

Michał Szydłowski
  • 3,261
  • 5
  • 33
  • 55

1 Answers1

0

Please note HTML Parser is the correct way to do this task. But if you want to match some opening and closing tags then you can achieve it like this in java(replace Foo with your tag)

<Foo\\b[^>]*>(.*?)</Foo>

Demo

sol4me
  • 15,233
  • 5
  • 34
  • 34