In Notepad++ to replace, hit Ctrl+H to open the Replace menu.
Then if you check the "Regular expression" button and you want in your replacement to use a part of your matching pattern, you must use "capture groups" (read more on google). For example, let's say that you want to match each of the following lines
value="4"
value="403"
value="200"
value="201"
value="116"
value="15"
using the .*"d+"
pattern and want to keep only the number. You can then use a capture group in your matching pattern, using parentheses (
and )
, like that: .*"(d+)"
. So now in your replacement you can simply write $1
, where $1 references to the value of the 1st capturing group and will return the number for each successful match. If you had two capture groups, for example (.*)="(d+)"
, $1
will return the string value
and $2
will return the number.
So by using:
Find: .*"(d+)"
Replace: $1
It will return you
4
403
200
201
116
15
Please note that there many alternate and better ways of matching the aforementioned pattern. For example the pattern value="([0-9]+)"
would be better, since it is more specific and you will be sure that it will match only these lines. It's even possible of making the replacement without the use of capture groups, but this is a slightly more advanced topic, so I'll leave it for now :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…