Answer the question
In order to leave comments, you need to log in
How to set a regular expression to find pieces of text with text?
Hello.
It seems to be simple, but I can't figure out how to do it.
There are many list items <li>текст</li>
. I need to select all chunks that have a phrase in their text, like "a year ago". The text also has other html tags.
Such regular expression (php) /<li.+год\ назад.+<\/li>/Us
takes away from the first <li> до последнего </li>
How to find separate li?
Answer the question
In order to leave comments, you need to log in
you need to reduce the pluses of greed by putting questions after them.
.+x -- up to the last character 'x'
.+? -- everything up to the first character 'x'
doesn't work at all. In this example, if you add another one on top, <li>erfgertwertwer</li>
then it will be taken. In addition, \w\s will not skip other html tags.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question