Simple \1\2\3 to \3\1

A swapping-ground for Regular Expression syntax

Simple \1\2\3 to \3\1

Postby Jack2 » Mon Aug 14, 2023 1:28 pm

Hi

I'm sure this should be easy, but I'm getting nowhere with my attempts.

I want to change the SOURCE:
Part1Part2Part3

where
Part1 is a text string always in the format: s0Xd0YtZZ
X, Y and Z are numerics that vary, the other bits are always the same. Part1 is always 9 characters long.

Part2 is always a single space, the first that occurs

Part3 is whatever remains of the full string, right upto the end of the filename. It will contain a variable number of alphas, numerics and spaces. Its length will vary.

-----

I want to change this TO TARGET:
Part3Part1


examples:
FROM:
s01d04t23 The Ra1n in Sp4ain
TO:
The Ra1n in Sp4ains01d04t23


FROM:
s03e09t02 The qu1ck lazy fox
TO:
The qu1ck lazy foxs03e09t02


- - -

Worst case, I could also compromise and live-with just changing it to TARGET:
Part3Part1Part2
...if that is necessary (i.e having a space (Part2) as the final character).

- - -

I have been trying various stuff with (.*?) and (.*?), but can't make it work...

thanks very much

(p.s. there is also a file extension, but that remains the same throughout)
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm

Re: Simple \1\2\3 to \3\1

Postby therube » Mon Aug 14, 2023 3:54 pm

1:RegEx, enable, Simple
Code: Select all
Match:  %1 %2 %3
Replace:  %2 %3%1

%1 matches, s##...
<sp>
%2 matches, The (the first word after s##...)
<sp>
%3 matches, everything else

Rearrange as wanted.

Code: Select all
s01d04t23 The Ra1n in Sp4ain
->   The Ra1n in Sp4ains01d04t23
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Simple \1\2\3 to \3\1

Postby Jack2 » Mon Aug 14, 2023 6:00 pm

awesome, thanks
:)
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm

Re: Simple \1\2\3 to \3\1

Postby Jack2 » Mon Aug 14, 2023 7:52 pm

err, sorry - I thought I had posted this in the Regex sub-forum. Please move this thread if appropriate.
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm


Return to Regular Expressions


cron