Find and replace using wildcard character in Notepad++
31,422
This replace should do it if I understand exactly what you want to accomplish:
Related videos on Youtube
Author by
Evanss
Updated on September 18, 2022Comments
-
Evanss over 1 year
I have very long list in this format:
<option value="adf">Option 1</option> <option value="es3">Option 2</option> <option value="34f">Option 3</option>
With Notpad++, how can I do a find and replace to change it to this format?:
<value="1">Option 1</option> <value="1">Option 2</option> <value="1">Option 3</option>
-
sean christe over 11 yearsHope it isn't XML or HTML since that would break it.
-
MetaGuru over 11 yearsDid you really mean to make all the values = 1 or are they suppose to = the number of the option, so in this case they would be 1, 2, 3 respectively?
-
amiregelz over 11 years@ioSamurai I thought it might have been a mistake too; it doesn't make much sense.
-
xiamx over 11 yearsIt's not really a good idea to use regex on xml.. Ideally, feed the xml to a parser then regenerate it to the format that you desire. see: stackoverflow.com/questions/1732348/…
-
-
sean christe over 11 yearsIf the option numbe goes to multiple digits, change (\d) to (\d+)
-
amiregelz over 11 yearsNo need to mess with the name of the option at all (e.g
Option 1
) - you only need to change the opening option tag, i.e replacing<option value=".*">
with<value="1">
. -
sean christe over 11 yearsthat is true. I usually do very explicit regexes then genralize them down later.