Regexp - search for text that does not contain a whole word

I have text similar to this:

<html><p>this is <b>the</b> text</p> and <p>this is another text</p></html>

and i need to get this text using regexp

this is <b>the</b> text

The problem is that when I use a simple regular expression like this ( <html>.*</p>), I get all the text until the last occurrence</p>

Can anybody help me?

thanks lennyd

+3
source share
4 answers

You need an unwanted match:

<html>.*?</p>

Alternatively, you might consider using an HTML parser instead of regular expressions for this task.

+3
source

, .. . , "" . *?

+2

, regexp /<p>(.*)(?=<\/p>)/, , .*? , . , HTML , :

  • para . HTML- para, .
  • :) .
0

, - , - ? , - [^<]

0

Source: https://habr.com/ru/post/1731696/


All Articles