Community
    • Login

    Find files with multiple Strings

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 3.4k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • VijayPrabakarV Offline
      VijayPrabakar
      last edited by

      ``

      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.

      ‘’

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Online
        Alan Kilborn @VijayPrabakar
        last edited by

        @vijay-S

        Maybe try something like this:

        (?s)(abc).+?(def)|(?2).+?(?1)

        1 Reply Last reply Reply Quote 1
        • VijayPrabakarV Offline
          VijayPrabakar
          last edited by

          @Alan-Kilborn said in Find files with multiple Strings:

          (?s)(abc).+?(def)|(?2).+?(?1)

          ``
          Works like a charm. Thank You…
          ‘’

          1 Reply Last reply Reply Quote 1
          • guy038G Offline
            guy038
            last edited by

            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 strings abc, def , ghi and jkl, in any order and whatever their case !

            Best Regards

            guy038

            PeterJonesP 1 Reply Last reply Reply Quote 1
            • PeterJonesP Offline
              PeterJones @guy038
              last edited by PeterJones

              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.

              1 Reply Last reply Reply Quote 0

              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
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors