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.
    • PingponguinP
      Pingponguin
      last edited by Pingponguin

      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

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

        @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
        • PingponguinP
          Pingponguin
          last edited by

          @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
          • PeterJonesP
            PeterJones
            last edited by

            @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
            • PingponguinP
              Pingponguin
              last edited by

              @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.

              Meta ChuhM 1 Reply Last reply Reply Quote 2
              • Meta ChuhM
                Meta Chuh moderator @Pingponguin
                last edited by

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