Community
    • Login

    Search and replace with wildcards

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 2.8k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              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 Offline
                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

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors