Problem 1.

For this problem I used the regular expression below. This expression finds two or more spaces which can then be replaced with a comma.

String

First String    Second      1.22      3.4
Second          More Text   1.555555  2.2220
Third           x           3         124

Solution

search: \s{2,}
replace: ,

Results

First String,Second,1.2,3.4
Second,More Tex,1.55555,2.2220
Third,x3,124

Problem 2

For this problem I searched using a regular expression that divided the string into specific elements. This allowed me to then make a replacement that changed the original order of the string and insert additional characters. See below.

String

Ballif, Bryan, University of Vermont
Ellison, Aaron, Harvard Forest
Record, Sydne, Bryn Mawr

Solution

search: (\w+),\s(\w+),\s(.*)
replace: \2 \1 (\3)

Results

Bryan Ballif (University of Vermont)
Aaron Ellison (Harvard Forest)
Sydne Record (Bryn Mawr)

Problem 3

This problem required two steps to complete. The first search and replace specifically targeted a custom character which was “mp3” and replaced that character with the same character -“mp3”- followed by a line break.

The second operation searched for specific elements which could then be reorganized in the final replace. The song title was retained by searching or everything between a space and “.mp3.”

String

0001 Georgia Horseshoe.mp3 0002 Billy In The Lowground.mp3 003 Cherokee Shuffle.mp3 0004 Walking Cane.mp3

Solution

search1: mp3 
replace1: mp3\n

search2: (\d+)\s(.*)(.mp3)
replace2: \2_\1\3

Results

Georgia Horseshoe_0001.mp3
Billy In The Lowground_0002.mp3
Cherokee Shuffle_0003.mp3
Walking Cane_0004.mp3

Problem 4

This problem also required two steps to complete. The first operation defined elements which can be manipulated later in the replace. The first operation needed to specifically select the capital letter associated with the genus name because this will be retained after the replace. The last two degits needed to be isolated as a seperate element inorder for it to be reatained in the the replace.

The second search selected the first 6 characters which included the Capital letter of the genus name, the “_“, and the first four letters of the species name. The last two numbers of the string were also retained.

String

Camponotus,pennsylvanicus,10.2,44
Camponotus,herculeanus,10.5,3
Myrmica,punctiventris,12.2,4
Lasius,neoniger,3.3,55

Solution

search1: ([A-Z])(\w+)\,(.*)\,(.*)\,(\d*) 
replace1: \1_\3,\5

search2: (\w{6})(\w+)\,(\d*)
replace2: \1,\3

Results

C_penn,44
C_herc,3
M_punc,4
L_neon,55