Mark Hardin
Mark Hardin

Reputation: 557

Javascript Multiple Word Regex

I am working with the jQuery datatables library and passing a regular expression to filter a particular column.

I'd like to pass something like "Test 123" and "Test 321" and it return any rows with either of those two words.

I have tried something like this without any luck:

/(?=.*?TEST 123)(?=.*?TEST 321).*/i

I've also tried this, but only returns the second result

TEST 123|TEST 321

Thanks in advance!

Upvotes: 1

Views: 588

Answers (2)

Jay Blanchard
Jay Blanchard

Reputation: 34416

Added the 'OR' condition to the test -

(TEST 123)|(TEST 321)

Tested at http://regexpal.com

Upvotes: 1

Yury Tarabanko
Yury Tarabanko

Reputation: 45121

Try this

/(TEST 123)|(TEST 321)/i

Upvotes: 1

Related Questions