Regex for string contains?

GurdeepS picture GurdeepS · Feb 15, 2011 · Viewed 502.9k times · Source

What is the regex for simply checking if a string contains a certain word (e.g. 'Test')? I've done some googling but can't get a straight example of such a regex. This is for a build script but has no bearing to any particular programming language.

Answer

Platinum Azure picture Platinum Azure · Feb 15, 2011

Just don't anchor your pattern:

/Test/

The above regex will check for the literal string "Test" being found somewhere within it.