Reputation: 1069
I have strings on a new line. Its music content, the thing is.. I need the Artist to be on the left side and track name to be on the right. So Artist - Track. Thing is, I have it Track - Artist.
Is there anything I can use to do such a thing? I searched around and either I am not searching for the correct words or there is nothing relating.
I am hoping to accomplish it with notepad ++ but if there's some online tool or perhaps another to do it then that would be great!
Input:
The Christmas Song (Chestnuts Roasting on an Open Fire) - Pentatonix
Real Love - Tom Odell
Winter - Joshua Radin
White Christmas - Katy Perry
Another Christmas - Amanda Jenssen
Output:
Pentatonix - The Christmas Song (Chestnuts Roasting on an Open Fire)
Tom Odell - Real Love
Joshua Radin - Winter
Katy Perry - White Christmas
Amanda Jenssen - Another Christmas
Upvotes: 0
Views: 964
Reputation: 44378
Use the following Regex, that captures the groups.
^(.*?)\s+-\s+(.*?)$
In Notepad++ you can substitute groups $1
and $2
captured and place them correctly as you wish.
$2 - $1
Check the demo on Regex101.
Upvotes: 2
Reputation: 91385
You could simply do:
^([^-]+) +- +(.+)$
$2 - $1
Explanation:
^ : begining of line
([^-]+) : group 1 everything that is not a dash
- : a dash with spaces around it
(.*) : group 2, rest of the line
$ : end of line
Upvotes: 2
Reputation: 1069
Source: https://superuser.com/questions/261072/reverse-name-order-in-notepad
Tool: Regex
Open up notepad++ and press CTRL + F to bring up the search box or navigate to Search - Find. Go to replace and switch the mode to Regular Expression. Now input in the Find What section: ^(.+) - (.+)$
and Replace With: \2 - \1
. Hit replace all and away it goes!
Find What: ^(.+) - (.+)$
Replace With: \2 - \1
Upvotes: 0
Reputation: 1474
If your delimiter SPACE-SPACE is consistent then use groups to swap the position of artist and track
(.+)(\s-\s)(.+)
Upvotes: 0