Page 1 of 1

regex to rearrange string

Posted: Wed Oct 26, 2016 10:45 am
by bennyutzer
hi there,

i have a basic knowledge of regex, but i came across a problem that exceeded my skills. i have a string like this:

[text][AB] SomeText (26-10-2016)[/text]

and using regex i want to transform it to:

[text][AB] 2016.10.26 - SomeText[/text]

is that possible? what regex command could i use for this?

greetz

Re: regex to rearrange string

Posted: Wed Oct 26, 2016 12:30 pm
by requinix
Regular expressions don't have "commands".

Match each portion of the string that you want to deal with, then put each into the substitution string wherever you want. For example, the search and replace could be

Code: Select all

\[(..)\] (.*?) \((\d\d)-(\d\d)-(\d\d\d\d)\)

Code: Select all

[\1] \5.\4.\3 - \2
The [AB] doesn't change so actually you could just ignore that part.