Search and replace with wildcards



  • 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



  • @Pingponguin

    Do a regular expression replace operation:

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



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



  • @Pingponguin said:

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

    We have a FAQ on that. :-)



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



  • @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)


Log in to reply