Dates (SOLVED)

A swapping-ground for Regular Expression syntax

Dates (SOLVED)

Postby kingsolo » Sat May 15, 2010 8:30 am

Okay, this is my first attempt at this, so let me see if I found everything in the forums I need. 2 different scenarios:

#1-

FROM:
The Lovely Bones - 2009.avi
TO:
The Lovely Bones (2009).avi
Do:
RegEx(1)
Match: (.+)(\d\d\d\d)
Repla: \1(\2)

Repl(3)
Replace: " - "
With: ""

#2
FROM:
Gossip Girl - S04E10 - 2010.avi
TO:
Gossip Girl S04E10.avi
Do:
RegEx(1)
Match: (.+)(\d\d\d\d)
Repla: \1 \2 (\3)

Repl(3)
Replace: " - "
With: ""

Is this correct?
Last edited by kingsolo on Sun May 16, 2010 12:24 pm, edited 1 time in total.
kingsolo
 
Posts: 2
Joined: Sat May 15, 2010 8:14 am

Re: Dates

Postby Stefan » Sat May 15, 2010 10:04 am

kingsolo wrote:Okay, this is my first attempt at this, so let me see if I found everything in the forums I need. 2 different scenarios:

#1-

FROM:
The Lovely Bones - 2009.avi
TO:
The Lovely Bones (2009).avi
Do:
RegEx(1)
Match: (.+)(\d\d\d\d)
Repla: \1(\2)

Repl(3)
Replace: " - "
With: ""

#2
FROM:
Gossip Girl - S04E10 - 2010.avi
TO:
Gossip Girl S04E10.avi
Do:
RegEx(1)
Match: (.+)(\d\d\d\d)
Repla: \1 \2 (\3)

Repl(3)
Replace: " - "
With: ""

Is this correct?

Hi kingsolo, welcome.

kingsolo> "Is this correct?"
If it works for you, then yes :D
(there is no wrong or right, all depends of your real file names and of your needs)

Lets see what i would do:
(untested from my side, please test with some copies of your real files)


-----------------------------------------------
FROM:
The Lovely Bones - 2009.avi
TO:
The Lovely Bones (2009).avi
Do:
RegEx(1)
Match: (.+) - (\d\d\d\d)
[Explanation: (find all till), space, dash, space, (four digits)]
Repla: \1 (\2)
[Explanation: replace whit what is matched by the regex inside the first (...), dropping the middle part, insert an '(', paste what is
matched by the regex inside of the second (...), insert an ')' ]

-----------------------------------------------

FROM:
Gossip Girl - S04E10 - 2010.avi
TO:
Gossip Girl S04E10.avi
Do:
RegEx(1)
Match: (.+) - \d\d\d\d
[Explanation: (find all till), space, dash, space, four digits]
Repla: \1
[Explanation: replace whit what is matched by the regex inside the first (...), dropping the dash and the 4 digits.]

Repl(3)
Replace: " - "
With: ""

----------------------------------------------- OR

FROM:
Gossip Girl - S04E10 - 2010.avi
TO:
Gossip Girl S04E10.avi
Do:
RegEx(1)
Match: (.+) - (.+) - \d\d\d\d
[Explanation: (find all till), space, dash, space, (find all till), space, dash, space, four digits]
Repla: \1 \2
[Explanation: replace whit what is matched by the regex inside the first (...), dropping the first dash,
paste in what is matched by the regex inside the second (...), dropping the second dash and the 4 digits.]

-----------------------------------------------

HTH? :D
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Dates

Postby kingsolo » Sat May 15, 2010 10:07 am

Thanks... will give it a shot when I get home. Appreciate the reply.

Edit- worked like a champ! Thanks!
kingsolo
 
Posts: 2
Joined: Sat May 15, 2010 8:14 am


Return to Regular Expressions