in reply to matching multiline regular expressions
This assumes that your 'keyword' is in $key. Note that the word/non-word construct is only repeated twice, though you have specified "three or more words." Following what you wrote, I couldn't guarantee that there would be any non-word after the third word, except for the newline which must be matched immediately prior to the end of string '$'./^$key\n\n(\w+\W+){2}\w+.*\n$/;
If there will always be at least one non-word character between the third word and the terminating newline, you can simplify the regex just a little:
/^$key\n\n(\w+\W+){3}.*\n$/;
Hope this is what you were looking for.
|
|---|