Community
    • Login

    Search two or more phrases in one single line

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 1.3k 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.
    • Rob de KleijnR
      Rob de Kleijn
      last edited by

      Example i have a log file with a line with this contents

      2020-12-10 01:01:48 185.248.238.155 EG12S009\7306 FTPSVC2 EG12S009 - 10.45.13.4 21 STOR AP_7306202012100200.lck 226 0 0 66 47063747 19469 90d40aa2-936c-424f-a1e2-63141adfa8f2 /Qdisplay/AP_7306202012100200.lck -

      To finding this line i want to search for “STOR AP_7306” and “185.248.238.155”

      How todo within Notepad++

      Thanks for responding…

      Rob

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Rob de Kleijn
        last edited by PeterJones

        @Rob-de-Kleijn ,

        To clarify, do you want to

        1. Find all lines that have both, in the order you listed
        2. Find all lines that have both, in either order
        3. Find all lines that have at least one of those two words

        Are you going to want to

        1. Just easily go to that line using “find next”
        2. highlight one or both of the matching words on that line
        3. bookmark all the lines that match
        4. do some sort of “replace” operation that you haven’t told us about
        5. delete all the lines that match
        6. delete all the lines that don’t match

        ----

        Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as plain text using the </> toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get… Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

        1 Reply Last reply Reply Quote 2
        • Alan KilbornA
          Alan Kilborn
          last edited by Alan Kilborn

          For this one, I’d go with the simplest explanation possible based upon what was provided, and let the OP sort it out from there.

          find: (?-s)(?=.*STOR AP_7306)(?=.*185\.248\.238\.155).*
          search mode: regular expression

          to extend to “or more”, do it like this:

          find: (?-s)(?=.*STOR AP_7306)(?=.*185\.248\.238\.155)(?=.*orMore)(?=.*orMore2).*

          perhaps you can see the pattern in the “orMore” stuff?

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