Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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>
share|improve this question
    
Hope it isn't XML or HTML since that would break it. –  EBGreen Nov 30 '12 at 18:21
    
No, actually what i need to make is a little different but the example in my questions illustrates the concept. –  jdln Nov 30 '12 at 18:24
4  
Did 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? –  ioSamurai Nov 30 '12 at 19:07
    
@ioSamurai I thought it might have been a mistake too; it doesn't make much sense. –  amiregelz Nov 30 '12 at 19:11
    
It'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/… –  xiamx Nov 30 '12 at 19:27

1 Answer 1

up vote 1 down vote accepted

This replace should do it if I understand exactly what you want to accomplish:

enter image description here

share|improve this answer
    
If the option numbe goes to multiple digits, change (\d) to (\d+) –  EBGreen Nov 30 '12 at 18:28
2  
No 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">. –  amiregelz Nov 30 '12 at 19:03
    
that is true. I usually do very explicit regexes then genralize them down later. –  EBGreen Nov 30 '12 at 19:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.