Reputation: 2984
How can I search and replace in way described below. I would like have texts between >
and <
from this text:
<option value="something">Text a</option>
<option value="abc">Test</option>
<option value="abc1">System</option>
After search and replace I would like have:
Text a+Test+System
So for </option>
I can do Search and Replace like that:
</option>\r\n
replace to +
But how can I search and replace texts contains different value in here: <option value="something">
? I tried with
<option value="*">
but it seems not working.
Can I do these two Search and Replace in one Search and Replace dialog?
Upvotes: 2
Views: 19129
Reputation: 229058
You do it like this:
Make sure Regular Expression is selected.
<option value="(.*)">(.*)<
matches your option, the first .*
matches everything between the "
Place that in side parenthesis (.*)
which will create a group you later can refer to. Similarly,
the 2. (.*)
creates the 2. group, which matches the text between the >
and <
Then replace the matched text, using \1
and \2
to refer to the two captured groups:
<option value="\1">\2 test system<
Upvotes: 4
Reputation: 1035
Step 1: In the replace dialog, switch the search mode to "Regular expression", Search ^<.+\"> and then replace with an empty string.
Step 2: Switch the search mode to normal, Search </option> and replace with an empty string
Step 3. Switch the search mode to Extended(\n, \r ...) search \r\n and replace with +
Good luck.
Upvotes: 0
Reputation: 322
You can achieve this in two simple steps:
First search for <option value=".*">
and select the search mode to regular expression and replace it with empty string.
Secondly, replace </option>\r\n
with +
and use the search mode extended for this replacement.
Hope this will solve your problem.
Upvotes: 3