Community
    • Login

    Find files with multiple Strings

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 1.7k Views
    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
      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
        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
          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
            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
              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
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors