-1

I have a string that contains this (and another things):

the text<br> 
Text text text and mooore text...<br> 
Text text text and mooore text...<br>
Text text text and mooore text...<br>

I need a reg-ex to get the text between <br> tags and first text.

1 Answers1

1

Assuming you want this:

the text<br>\nText text text and mooore text...<br> 
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Regex: (?:<br>)([\s\S]*?)(?=<br>)

  1. (?:<br>) --> Ensure a <br> is there (do not match it)
  2. ([\s\S]*?) --> Match everything lazily and capture it.
  3. (?=<br>) --> Ensure a <br> follows.

Demo

P.S. As others have said, you cannot parse HTML tags as answered here.

Community
  • 1
  • 1
Gaurang Tandon
  • 6,504
  • 11
  • 47
  • 84