Search code examples
notepad++

Replacing numbers with asterisks


I want to replace multiple numbers with asterisks with Notepad++, how to? Example:

109.169.76.0/22
109.169.88.0/21
109.190.0.0/16
109.196.166.0/23
109.196.172.0/24
109.196.175.0/24
109.200.30.0/23
109.200.192.0/21
109.200.208.0/20
109.201.133.22/32
109.201.133.24/32
202.55.45.41/32

should become:

109.169.***.***
109.169.***.***
109.190.***.***
109.196.***.***
109.196.***.***
109.196.***.***
109.200.***.***
109.200.***.***
109.200.***.***
109.201.***.***
109.201.***.***
202.55.***.***

(Sorry if I didn't describe it clearly, but I want to replace anything after "NNN.NNN" with "***.***" (N is number) Thanks :)


Solution

    • Ctrl+H
    • Find what: \d+\.\d+/\d+$
    • Replace with: ***.***
    • CHECK Wrap around
    • CHECK Regular expression
    • Replace all

    Explanation:

    \d+         # 1 or more digits
    \.          # a dot
    \d+         # 1 or more digits
    /           # a slash
    \d+         # 1 or more digits
    $           # end of line
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here