0

I know I got BeautifulSoup, But I want to try my own.

Regex I've been working on

<br>This Text needed
<a>unwanted text</a>
<br/>
This text needed
<a >unwanted text</a>
 This text needed
<a>unwanted text</a>
<br>this text needed

What I have come up with:

(</a>|(<br(/>|>)))(\s.*|\w.*)

I want to match the This text needed but one of them isn't matching.

Tobias Wilfert
  • 919
  • 3
  • 14
  • 26
Ena jaqis
  • 13
  • 1

1 Answers1

0

How about this way with lookahead negative and lookbehind positive,

(?<!<a>)This Text needed(?!<\/a>)

DEMO: https://regex101.com/r/RT5LZu/1

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103