• Login
Community
  • Login

Search and replace with wildcards

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 Posters 2.2k 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
    Pingponguin
    last edited by Pingponguin Feb 23, 2019, 12:23 PM Feb 23, 2019, 12:21 PM

    Hello,

    I need to replace many IP addresses in a large log-file.
    Most of them do look like this “remoteAddr”:“1.2.3.4”
    I need to replace all IPs with ***
    Is there a way I can search for all IPs with wildcards and replace them with *** in one step?

    Thanks and regards Pingpong

    A 1 Reply Last reply Feb 23, 2019, 1:52 PM Reply Quote 0
    • A
      Alan Kilborn @Pingponguin
      last edited by Feb 23, 2019, 1:52 PM

      @Pingponguin

      Do a regular expression replace operation:

      Find: "remoteAddr":"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}"
      Replace: "remoteAddr":"*.*.*.*"

      1 Reply Last reply Reply Quote 3
      • P
        Pingponguin
        last edited by Feb 23, 2019, 3:04 PM

        @Alan-Kilborn said:

        regular expression replace

        Thank you very much. I looked into regular expressions before but did not really understand it.
        You example worked just find and I understand a little bit better what regular expressions is about.
        This will help me in the future.

        1 Reply Last reply Reply Quote 3
        • P
          PeterJones
          last edited by Feb 23, 2019, 5:28 PM

          @Pingponguin said:

          I looked into regular expressions before but did not really understand it.

          We have a FAQ on that. :-)

          1 Reply Last reply Reply Quote 2
          • P
            Pingponguin
            last edited by Feb 23, 2019, 5:47 PM

            @PeterJones

            I know and I followed the noob path but really did not understand how this should help me with my question.
            With @Alan-Kilborn s example I got the point and now I can work with the faq and the N++ Wiki entry for REGEX.

            M 1 Reply Last reply Feb 23, 2019, 6:26 PM Reply Quote 2
            • M
              Meta Chuh moderator @Pingponguin
              last edited by Feb 23, 2019, 6:26 PM

              @Pingponguin

              I followed the noob path but really did not understand how this should help me with my question.

              yes, i can relate completely.
              whilst we (as the notepad++ community) do have a vast library of regex examples and guides, it can be difficult to get a first firm grip at regex, without having a few real life examples, one can personally relate to.

              also there are some vast differences on how different users reach the same results with almost completely different syntaxes (let’s call them “personal regex dialects”).
              for example @Alan-Kilborn 's regex syntax for your request is perfect to begin with, because it is as easy as possible to read and understand.

              but if you stick around, you will also see regexes that often do the same and are very difficult to digest.
              (i usually still stick to syntaxes i can completely understand and/or are easier to break down to smaller parts)

              1 Reply Last reply Reply Quote 2
              4 out of 6
              • First post
                4/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors