Changing the order of tokens. 3 renaming tasks needed.

A swapping-ground for Regular Expression syntax

Changing the order of tokens. 3 renaming tasks needed.

Postby parker » Sat Feb 06, 2021 2:32 pm

The tokens are separated by spaces.

==========================================
TASK 1. I want to reverse the first two tokens.

I want to rename:
Abm 66 (Reggae) Classic Reggae 105

to
66 Abm (Reggae) Classic Reggae 105
========================================
TASK 2. I want to place tokens 1 and 2 after token 3.

I want to rename:
Abm 66 (Reggae) Classic Reggae 105

to
(Reggae) Abm 66 Classic Reggae 105
========================================
TASK 3. I want to:
• Put token 1 in 3rd place.
• Keep token 2 in 2nd place.
• Put token 3 in 1st place.


I want to rename:
Abm 66 (Reggae) Classic Reggae 105

to
(Reggae) 66 Abm Classic Reggae 105
=================================
And keep everything after the first 3 tokens unchanged.

This seems like a pretty tall order. I would be amazed if someone could figure this out
Thank You for any help with this.
parker
 
Posts: 9
Joined: Mon Dec 01, 2008 10:30 am

Re: Changing the order of tokens. 3 renaming tasks needed.

Postby Luuk » Sat Feb 06, 2021 4:33 pm

This is the "Match" and "Replace" for each task, for when space does always separate the tokens...

TASK1: Tokens123 -> 213
(.+?) (.+?) (.+)
\2 \1 \3

TASK2: Tokens1234 --> 3124
(.+?) (.+?) (.+?) (.+)
\3 \1 \2 \4

TASK3: Tokens1234 --> 3214
(.+?) (.+?) (.+?) (.+)
\3 \2 \1 \4
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Changing the order of tokens. 3 renaming tasks needed.

Postby parker » Sat Feb 06, 2021 5:12 pm

Thank you. Great.

One more task.

Last token first. The filenames have different amounts of tokens. 5, 6 and 7
parker
 
Posts: 9
Joined: Mon Dec 01, 2008 10:30 am

Re: Changing the order of tokens. 3 renaming tasks needed.

Postby Luuk » Sat Feb 06, 2021 5:29 pm

For last token first, the Match and Replace can be ...
(.+) (.+)
\2 \1
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Changing the order of tokens. 3 renaming tasks needed.

Postby parker » Sat Feb 06, 2021 5:47 pm

Thank you very much
parker
 
Posts: 9
Joined: Mon Dec 01, 2008 10:30 am


Return to Regular Expressions