Reputation: 155
I have a piece of code in Atom that looks like this:
replace party ="0001" "FEDERALIST"
replace party ="0008" "ANTI-DEMOCRAT"
replace party ="0009" "JEFFERSON REPUBLICAN"
And I want it to look like this:
replace party ="FEDERALIST" "0001"
replace party ="ANTI-DEMOCRAT" "0008"
replace party ="JEFFERSON REPUBLICAN" "0009"
I know I can use regular expressions to find the relevant pieces of text, but I was not able to find a way to rearrange the order of the code within each line. I was wondering if something like finding "[\d]{4}"
and replacing it with \"[A-Z- ]+\"
is possible.
Upvotes: 2
Views: 95
Reputation: 626870
You may use
Find What: ("\d{4}") ("[^"]*") *$
Replace With: $2 $1
See the regex demo.
Details
("\d{4}")
- Capturing group 1: "
, 4 digits and "
- a space("[^"]*")
- Capturing group 2: "
, 0+ chars other than "
and then "
*
- 0+ spaces$
- end of line.Upvotes: 3