Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex match two words in a string

Tags:

regex

I'm trying to match (look for) two words in a string which is as follows:

Mac OS X/10.11.5 (15F34); ExchangeWebServices/6.0 (243);

I want to match (true) if we see "Mac" AND "ExchangeWebServices" but the characters between the two words would be unknown/random. Can someone help me with the regex syntax?

Thanks!

like image 678
Jason Shave Avatar asked Nov 30 '22 23:11

Jason Shave


1 Answers

This will match exactly the words "Mac" and "ExchangeWebServices" with anything else between them:

\bMac\b.*\bExchangeWebServices\b

Regex 101 Example: https://regex101.com/r/sK2qG1/4

like image 80
Jim Avatar answered Dec 06 '22 08:12

Jim