Find: \h+
Replace: ,
I used \h+
to capture all spaces and replaced them with a single comma.
Result
First,String,Second,1.22,3.4
Second,More,Text,1.555555,2.2220
Third,x,3,124
Find: (\w+), (\w+), (.*)
Replace: \2 \1 (\3)
I used ()
and \w+
to capture target pieces of text and put them in desired order with \1, \2, and \3
.
Result
Bryan Ballif (University of Vermont)
Aaron Ellison (Harvard Forest)
Sydne Record (Bryn Mawr)
Find: \d
Replace: \n0
I used \d
to capture the specific text piece space0
and replaced with \n0
, for which I hard-coded in the number 0.
Result
0001 Georgia Horseshoe.mp3
0002 Billy In The Lowground.mp3
0003 Cherokee Shuffle.mp3
0004 Walking Cane.mp3
Find: (\d{4}) (.+).mp3
Replace: \2_\1.mp3
I used the wildcard \d
with quantifier {4}
to specify the first four digits and (.+)
to extract the title, and re-ordered them with \2_\1
.
Result
Georgia Horseshoe_0001.mp3
Billy In The Lowground_0002.mp3
Cherokee Shuffle_0003.mp3
Walking Cane_0004.mp3
Find: (\w)\w+,(\w+).*,(\d*)
Replace: \1_\2,\3
Not a neat regular expression definitely, but I hard-coded in the format and used wildcards with ()
to capture the desired pieces of text and put them in the new format.
Result
C_pennsylvanicus,44
C_herculeanus,3
M_punctiventris,4
L_neoniger,55
Find: (\w)\w+,(\w{4}).*,(\d*)
Replace: \1_\2,\3
I changed the quantifier in the second ()
to {4}
to just extract the four letters of species name.
Result
C_penn,44
C_herc,3
M_punc,4
L_neon,55
Find: (\w{3})\w+,(\w{3})\w+,(.*),(\d*)
Replace: \1\2, \4, \3
Still, I designed the find and replace terms to match the desired formats while used ()
and \1,\2,\3,\4
to capture target pieces of text and re-order them.
Result
Campen, 44, 10.2
Camher, 3, 10.5
Myrpun, 4, 12.2
Lasneo, 55, 3.3