Find files with multiple Strings
-
``
I want to find all the files which has both the strings in any order.
string are; abc and def or def and abc.
The result should return only the files which has both the string in a file.
‘’
-
@vijay-S
Maybe try something like this:
(?s)(abc).+?(def)|(?2).+?(?1) -
@Alan-Kilborn said in Find files with multiple Strings:
(?s)(abc).+?(def)|(?2).+?(?1)
``
Works like a charm. Thank You…
‘’ -
Hello, @vijay-s @alan-kilborn and All,
As @alan-kilborn, I’ve already used this method. However, it quickly becomes tedious if you increase the number of expressions :-((
I think, that this other formulation is stronger and can be easily used, even if more than two expressions to match !
-
(?-is)^(?=.*Expr_1)(?=.*Expr_2)(?=.*Expr_3)…(?=.*Expr_n).+( sensitive to case ) -
(?i-s)^(?=.*Expr_1)(?=.*Expr_2)(?=.*Expr_3)…(?=.*Expr_n).+( insensitive to case )
For instance, the regex
(?i-s)^(?=.*abc)(?=.*def)(?=.*ghi)(?=.*jkl).+will find all files which have, at least, one line containing the four stringsabc,def,ghiandjkl, in any order and whatever their case !Best Regards
guy038
-
-
All,
See also my in-development expressions for generic logic “gates” in regular expressions: AND, OR, XOR, NOR, NAND
Some day, they might get a blog post all of their own, rather than be buried in that thread. But they are still in-development, so they’ll stay there for now.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login