I tried the answer of this post Regex. Find paragraph containing some word, in my case that would be
((?!\n\n).)*(cat)
, but this don't work.
How can I use PCRE2 regular expressions (PHP >= 7.3) to match all paragraphs in my text that contain the word "cat", where each paragraph is separated by two consecutive line breaks (It is allowed to have one line break in a paragraph but not two)?
For example, if the input text is as follow
Paragraph 1 wepfowfpo
fww efwf
Paragraph 2 wefwf32321
!@d r33tcat54, 333!..
Paragraph 3 4t4t022
-`121231ere3r3cat342232
$ 4t0g cat rdwd203
$$333
Paragraph 4 222cocdo3
Then the desired ouput is
Paragraph 3 4t4t022
-`121231ere3r3cat342232
$ 4t0g cat rdwd203
$$333
I tried to use something like \n\n.*(?=cat)cat.*\n\n
, but this match only those lines contain "cat".