complex 0 removal

A swapping-ground for Regular Expression syntax

complex 0 removal

Postby Kittani » Mon Feb 16, 2009 1:26 am

Hey folks. I love this program first of all.

I used to consider myself a smart guy, but I have a very peculiar instance in managing a library of over 48000 files that only a REGEX can solve. I just can't figure it out.

Example.

Thisismyfilename 01.ext
Thisis07th file of 07.ext
303fileslater 09.ext
00000 000 07.ext

All of the above files for example would need to have the last 0 in the string removed, but none of the others, and allow for anything else that might be in the filename.

I tried to use this one

^(.+) ([0]) ([1-9])
\1\3

But it would remove everything between the first and last zero, including the zeroes.

How do I tell it to ONLY remove the LAST zero in the filename and ONLY if it is within the LAST two characters of the filename (extension not included)

Examples... again

Rename:
File40407 to File4047
File4047 no change
File07 to File7

Make Sense?

This is for my Soundpool library to be recognized by my software and grouped correctly. Unfortunately the files have to all end in a 1-7 and for whatever reason it breaks if it's preceeded by a 0, AND they have alot of filenames that have 0's in them as part of the filename.

Any suggestions?
Kittani
 
Posts: 1
Joined: Mon Feb 16, 2009 1:15 am

Re: complex 0 removal

Postby GMA » Mon Feb 16, 2009 8:44 am

Hi, Kittani:
I believe this should work:

MATCH: (.+)0([0-9])$
REPLACE: \1\2

Best regards,

Gabriel.
GMA
 
Posts: 91
Joined: Sun Dec 02, 2007 1:30 pm
Location: Argentina


Return to Regular Expressions