gcmd-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gcmd-dev] advrename


From: Piotr Eljasiak
Subject: Re: [gcmd-dev] advrename
Date: Mon, 01 Feb 2010 21:01:47 +0100

> Lotta downlots named like
> 
>       JunkPart_FooPart-ThingsToCome.msv
>       MoreJunk_AnotherFoo-ThingsToCome.msv
>       ...
> 
> and i'd like to cut the junk part to have it
> 
>       FooPart-ThingsToCome.msv
>       AnotherFoo-ThingsToCome.msv
>       ...

What you need is regex backreferences.. Basically speaking, it's just
grouping parts of a regular expression together using round brackets and
then referencing them.

Please use as regex:

        ([^_]+)_(.+)\.

and for replacement:

        \2.
        
([^_]+) stands for at least one char different from _, (.+)\. is for any
string ending with .

\2. means: replace the matched string with the second matched group and
dot.


This solution is not bullet-proof, but should work for any filename with
extension.


Piotr





reply via email to

[Prev in Thread] Current Thread [Next in Thread]