#1 2021-08-23 22:45

clak
Member
Registered: 2021-08-23
Posts: 2

RegEx or script to rearrange specific parts of a name

Hello smile

I'm currently trying to get a naming scheme like this:

Title (Year) [Publisher] [incomplete]

to this:

Title (Publisher, Year) [incomplete]

The [incomplete] part is only present in some names. The year can be either something like (2010), (2010-2012) or (since 2010). The title could eventually also contain something in parentheses. The year will always be before the publisher, so there will always be a ") [" between them.

I can't get this to work with RegEx.

Here are two examples:

Scott Pilgrim (Color Edition) (2004-2010) [Oni Press] -> Scott Pilgrim (Color Edition) (Oni Press, 2004-2010)
Polar (since 2015) [Popcom] [incomplete] -> Polar (Popcom, since 2015) [incomplete]

Any help is appreciated. Thanks and best regards!

Offline

#2 2021-08-24 08:37

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: RegEx or script to rearrange specific parts of a name

Hello,

Try this RegEx rule:

1) Regular Expressions: Replace expression "\(([^\)]+)\) \[([^\]]+)\]( \[incomplete\])?" with "($2, $1)$3" (skip extension)

From:

Scott Pilgrim (Color Edition) (2004-2010) [Oni Press]
Polar (since 2015) [Popcom] [incomplete]
Title (Something) (2004) [Two Words]
Three Title Words (2000-2021) [Three Publisher Words] [incomplete]

To:

Scott Pilgrim (Color Edition) (Oni Press, 2004-2010)
Polar (Popcom, since 2015) [incomplete]
Title (Something) (Two Words, 2004)
Three Title Words (Three Publisher Words, 2000-2021) [incomplete]


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#3 2021-08-24 17:39

clak
Member
Registered: 2021-08-23
Posts: 2

Re: RegEx or script to rearrange specific parts of a name

Hey,

thank you so much! This worked perfectly!

Have a great day!

Offline

Board footer

Powered by FluxBB