• Login
Community
  • Login

Search with two strings in line

Scheduled Pinned Locked Moved General Discussion
6 Posts 4 Posters 21.9k 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.
  • P
    Peter Reichmuth
    last edited by Jul 5, 2022, 6:29 AM

    Hi
    I want to search for lines in a text file, that contains the following two strings “CATALOG” and “FINISHED” somewhere in the line.

    Example:
    12:42:35,700 CATALOG [LSG_BRN_Gleisabschnitt_0021] FINISHED OK
    –> This is a valid result

    12:42:35,700 TEST [Testfall Gleisabschnitt BRN-GA_0021] FINISHED OK
    –> This is not a valid result, since the string “CATALOG” is missing in the line.

    How can I do such a search?
    Thanks Peter

    T 1 Reply Last reply Jul 5, 2022, 6:56 AM Reply Quote 0
    • T
      Terry R @Peter Reichmuth
      last edited by Terry R Jul 5, 2022, 6:56 AM Jul 5, 2022, 6:56 AM

      @Peter-Reichmuth said in Search with two strings in line:

      How can I do such a search?

      I know this was presented in the forum and after a while I found it. Try reading this post. It’s the AND option you need to look at.

      Terry

      1 Reply Last reply Reply Quote 0
      • G
        guy038
        last edited by guy038 Jul 5, 2022, 7:28 AM Jul 5, 2022, 7:01 AM

        Hello, @peter-reichmuth and All,

        Easy with regexes !

        • Open the Find or Mark dialog ( Ctrl + F / Ctrl + M )

        • SEARCH / MARK (?-is)^.*CATALOG.*FINISHED.*\R?

        • Tick the Wrap around option

        • Select the Regular expression search mode

        • Ckick on the Find Next or Find All in Current Document or Mark All button

        => Every complete line, containing these two strings, in this order, are selected or marked !


        In case that the word FINISHED may come before the word CATALOG, prefer that second version :

        • SEARCH / MARK (?-is)^.*(?:CATALOG.*FINISHED|FINISHED.*CATALOG).*\R?

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by guy038 Jul 5, 2022, 7:44 AM Jul 5, 2022, 7:23 AM

          Hi, @peter-reichmuth and All,

          Re-reading the post that @terry-r referred to, indeed, you may use that more simple solution :

          SEARCH / MARK (?-is)^(?=.*CATALOG)(?=.*FINISHED).+\R?

          => The complete lines, containing, both, the strings CATALOG and FINISHED, whatever their respective order, should be selected or marked !

          BR

          guy038

          P 1 Reply Last reply Jul 5, 2022, 7:37 AM Reply Quote 1
          • P
            Peter Reichmuth @guy038
            last edited by Jul 5, 2022, 7:37 AM

            @guy038 and All
            Thank you very much for your quick help!
            The solution works perfect and fits my need.
            Peter

            T 1 Reply Last reply Sep 17, 2024, 8:27 AM Reply Quote 1
            • T
              Taiwo tope @Peter Reichmuth
              last edited by Sep 17, 2024, 8:27 AM

              @Peter-Reichmuth please, exactly which one of the solutions work *perfectly

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors