Regular Expression Puzzles

Done in Notepad++ v8.7.5
 

1

Find: [ ]+
Replace: ,

Match (1 or more spaces).
Replace with (a comma).
 

2

Find: (\w+), (\w+), ([\w+ ]+)
Replace: \2 \1 \(\3\)

Match (multiple letters, a comma and space, multiple letters, a comma and space, and multiple letters then a space repeated once or more).
Replace with (the second group of multiple letters, the first group of multiple letters, then the third group of letters and spaces in parentheses).
 

3

Find: mp3
Replace: mp3\n

Match (the exact string ‘mp3’ then a space).
Replace with (‘mp3’ then a new line).
 

4

Find: (\d{4}) ([\w+ ]+)(.mp3)
Replace: \2_\1\3

Match (4 digits, a space, multiple letters, ‘.mp3’).
Replace with (the multiple letters, underscore, the four digits, ‘.mp3’).
 

5

Find: ([A-Z])\w+,(\w+),\d+.\d,(\d+)
Replace: \1_\2,\3

Match (an uppercase letter followed by one or more letters, comma, multiple letters, comma, one or more digits, a period, one digit, comma, one or more digits).
Replace with (the uppercase letter, underscore, the multiple letters, comma, the last digits).
 

6

Find: ([A-Z])\w+,(\w{4})\w*,\d+.\d,(\d+)
Replace: \1_\2,\3

Match (an uppercase letter followed four letters followed by zero or more letters, comma, multiple letters, comma, one or more digits, a period, one digit, comma, one or more digits).
Replace with (the uppercase letter, underscore, the four letters, comma, the last digits).
 

7

Find: (\w{3})\w*,(\w{3})\w*,(\d+.\d),(\d+)
Replace: \1\2, \4, \3

Match (three letters followed by zero or more letters, comma, three letters followed by zero or more letters, comma, one or more digits then a period then one digit, comma, one or more digits).
Replace with (the first three letters, the second three letters, the last digits, the group of digits period digit).
 

8

Find:
Replace:

Match (a space).
Replace with (nothing).
 

Find: ,NA,
Replace: ,,

Match (comma, ‘NA’, comma).
Replace with (two commas).
 

Find: [^,/.a-zA-Z\d\s:]
Replace:

Match (anything except comma, forward slash, letters, digits, and white space).
Replace with (nothing).

NOTE: this removes the snake_case formatting of the variable names

Alternate: (?:(?:(?:\w*)(?:[\*\?\@\%\#\$\&\-\)\(\^\!\+\_]+)(?:\w+))){1,}
 

Sources:
- https://stackoverflow.com/questions/6053541/regex-every-non-alphanumeric-character-except-white-space-or-colon