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
Post a Comment