Page 1 of 1

RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 07:40
by kalle
Hi all,

i tried to rename file, which contain a date in form yy mm dd (seperated by blanks) into yy-mm-dd without changing other appearing blanks.

So i formed the pattern (?<=\d)( )(?=\d) and tried it in Programmers Notepad and Notepad++, where it worked to find only those blanks with a number before and after.

But when i try (?<=\d)( )(?=\d) > - in the RegExp rename field, it tells me an Syntax Error... :(

Isn't that possible by RegEx in XYPlorer?

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 07:49
by highend
Welcome to the forum.
Isn't that possible by RegEx in XYPlorer?
Unfortunately, it's not. XY uses vbscript.dll for it's regex engine. It doesn't support lookbehind...

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 08:11
by kalle
Thank you for welcoming me and especially for the quick response.

I guess i have to look into scripting xy ... or would you or anyone have another (rather easy) suggestion?

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 08:53
by highend
Not elegant but should work:

Code: Select all

(\d+) (\d+) (\d+) > $1-$2-$3
Renames e.g.:

Code: Select all

hello 15 10 26 world.txt
into

Code: Select all

hello 15-10-26 world.txt

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 08:57
by bdeshi
you can try scripting with xypcre (by me :whistle: ), which supports some advanced regexp ops. However this will be an ugly & convulted process.
something like renameitem(oldname, pcrereplace(oldname, pattern, replacement)); //I'm not sure if the syntax is correct, awayfrompc.

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:03
by kalle
Amazing!

Thank's so much.

But now, aside this topic ... can i use $1, $2 as the opening (
like variables in RegEx

on the other hand, i tweaked your line into
(\d{1,2})[ .](\d{1,2})[ .](\d{1,2}) > $1-$2-$3
to allow 1 or 2 digit numbers and a dot or blank as seperator

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:13
by armsys
kalle wrote:... can i use $1, $2 as the opening ( like variables in RegEx
What do you mean?
Can you show us some sample text strings and expected results?

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:29
by kalle
it seems correct:

usage of $1, $2, and so on in renaming into always gives that substring which was found by the regex expression in the numbered brackets ($1) ($2)

That way was my very first attempt, but i was unable to figure the Syntax. How dumb one can think ^^

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:35
by highend
(\d{1,2})[ .](\d{1,2})[ .](\d{1,2}) > $1-$2-$3
You didn't mention that dots are possible separators in the first place :)

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:42
by kalle
Yes, that's true, i didn't mention dots as possible seperators to keep my question tight and small
Since i'm native german

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 09:47
by highend
Since i'm native german
My heartfelt sympathy! *feix*

Re: RegExp Rename (?<=\d)( )(?=\d) > -

Posted: 27 Oct 2015 10:22
by kalle
highend wrote: *feix*
Danke vielmals *grins*