Replace . (dot) with a white space

A swapping-ground for Regular Expression syntax

Replace . (dot) with a white space

Postby Fizzer » Mon Feb 14, 2011 9:23 am

Hello

Finally got what was a very long regex processing of a file name to remove the junk and format to my liking.

BUT 1 final hurdle remains.
I can not find a way to remove .'s (dot's) and relace them with white spaces.

e.g

FROM: my.backup.file.S01E11.all.this.removed.avi
TO: my backup file - 1x11.avi


I have gotten as far as:
my.backup.file - 1x11.avi

With the following RegEx:

MATCH: (.*)(\.S)([0-9]*)(E)(\d{2})

REPLACE: \1 - \3x\5


Apologies if it a bit n00bie. Only been doing RegEx for a day or so. BUt have learnt a fair amount (I think) :)
Fizzer
 
Posts: 2
Joined: Sun Feb 13, 2011 2:51 pm

Re: Replace . (dot) with a white space

Postby Stefan » Mon Feb 14, 2011 12:13 pm

I think you have to match each dot for it alone and replace with nothing

FROM: my.backup.file. <---and so on>
TO: my backup file <---and so on>

Match (.+)\.(.+)\.(.+)\.
Repla: \1 \2 \3


Explanation:
(.+) => match "my"
\. ===> match <dot>
(.+) => match "backup"
\. ===> match <dot>
(.+) => match "file"
\. ===> match <dot>


Maybe you have to search non-greedy like
Match (.+?)\.(.+?)\.(.+?)\.
Repla: \1 \2 \3
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions