regex to replace /swap the option value with the text in select

时间:2015-10-30 22:36:08

标签: regex replace notepad++

I have a ton of tedious options to edit and while I know several regex commands and tricks, I'm not able to figure out how to do the following:

Problem:
Business Team wants me to go in a swap out name and value reverse it

So instead of:

<option value="Miller Keisha S">Keisha.Miller@company.com</option>

I want to use notepad++ or whatever else and get

<option value="Keisha.Miller@company.com">Miller Keisha S</option>

I know $ is the end and ^ is the beginning but then all the forward and backslashes etc...

So I know that I would want to find everything that is in value=" and ends with "> and replace what starts with "> and ends with

I am looking at OTHER stackoverflow questions and https://www.regex101.com/

1 个答案:

答案 0 :(得分:1)

Search for:

<option value="([^"]+)">([^<]+)<\/option>

Replace with:

<option value="$2">$1</option>

Demo