Regular Expression to find term in and surrounding words

Use this regular expression to highlight a term in the middle of a sentence:

(?:\S+\s+){0,4}(money is good)\s*(?:\S+\b\s*){0,4}

Here is a great site to test the above regular expression:



Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top