Search and replace different values in notepad++

13,866

Solution 1

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.

Solution 2

You do it like this:

notpad++ search dialog

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<

Share:
13,866
Lucas
Author by

Lucas

Updated on June 17, 2022

Comments

  • Lucas
    Lucas almost 2 years

    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?