I have a string like this:
...
xxxx
xxx
keyword1 xxxxx
xxxx
xxxx
xxxxx keyword2 yyyy
xxx
xxxx
xxx
...
where the x and y's are just random chars. I need to match the first "keyword2 yyyy" that appears after keyword1, and there may be multiple lines after keyword1. How do I write the regular expression? Thanks!
You can use this regex,
^(?s).*keyword1.*?(keyword2 yyyy).*$
Explanation: