regex - Regular expression AND not matching correctly -


i want able search in set of documents on 2 words "country" , "vehicle"... want see documents have both words in them once document has both words, want hit on occurrences of either word.

i've tried

(?=(country|vehicle))  (?= country )(?= vehicle) ( (country)* | (vehicle)*) | ( (country .* vehicle) ) (?=.*vehicle)(?=.*country) 

i can't seem right, suggestions?

you need use single line option , anchor speed processing:

(?s)^(?=.*vehicle)(?=.*country) 

if need match words whole words, use \b word boundary around them.

without singleline mode, words checking might not reached might located on second, third etc. lines , lookaheads fail.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -