Page 1 of 2

Regex comments not working

Posted: 22 Aug 2007 07:01
by Muroph
Hey, its me again!

I usually add a comment as a title to the expressions in the RegExp Rename list.
Like this:

(?#ren 1st num)\D*(\d+).*(\.[0-9A-z]*$)>filename_$1$2

This should rename the file using the 1st sequence of numbers and the extension.
But it gives a syntax error message.
All regex with comments do.
The only way I found to avoid the error is to remove the comments.

The thing is: I've been using comments for a long time in v6.10 with no problems (using 6.20 now).
The expressions also worked with a regex debugger.

So... Is this a bug or I'm doing something wrong?

Re: Regex comments not working

Posted: 22 Aug 2007 07:45
by admin
Muroph wrote:The thing is: I've been using comments for a long time in v6.10 with no problems (using 6.20 now).
Nothing was changed in 6.2 concerning RegExp. I tried your example with 6.10 and it fails as well.

Posted: 22 Aug 2007 08:26
by Muroph
I just found this:
"Regex comments are supported by the JGsoft engine, .NET, Perl, PCRE, Python and Ruby."
"Java (...) doesn't support (?#)-style comments."
Maybe this is the cause.

And... well... I forgot a little detail...
I always erased the comments before applying the regex, so the templates would stand out in the history.
Really sorry about that... :oops:


Ah! Maybe THIS is a bug, but I won't create a new topic for it.
When you hit the shortcut 'Miscellaneous / Tree / Fully Collapse Drive' the tab/list also goes to the drive location.

Posted: 22 Aug 2007 11:37
by jacky
Yes, MS/VB engine used by XY does not support comments, so nothing Don can do about it.
Muroph wrote:When you hit the shortcut 'Miscellaneous / Tree / Fully Collapse Drive' the tab/list also goes to the drive location.
Of course it does, since you cannot be on a location not shown on Tree! As soon as you collapse a parent folder of your current location, you'll jump to that parent.

Same apply here, it's even hinted in the description: "Fully collapse the current drive (resp. \\Server, Desktop, MyDocuments) in Tree. Select and focus the drive root."

Posted: 22 Aug 2007 12:32
by admin
jacky wrote:Yes, MS/VB engine used by XY does not support comments, so nothing Don can do about it.
Oh, I can: cut the comment! :) Help me, what's the comment syntax? Start with "(?", end with ")" ??

Posted: 22 Aug 2007 13:51
by jacky
admin wrote:
jacky wrote:Yes, MS/VB engine used by XY does not support comments, so nothing Don can do about it.
Oh, I can: cut the comment! :) Help me, what's the comment syntax? Start with "(?", end with ")" ??
Oh yeah, you could do this... you almost got ir right, syntax is (?#comment)

Posted: 22 Aug 2007 14:15
by admin
jacky wrote:
admin wrote:
jacky wrote:Yes, MS/VB engine used by XY does not support comments, so nothing Don can do about it.
Oh, I can: cut the comment! :) Help me, what's the comment syntax? Start with "(?", end with ")" ??
Oh yeah, you could do this... you almost got ir right, syntax is (?#comment)
Always at the beginning? Or anywhere? If anywhere, are multiple comments allowed?

Posted: 22 Aug 2007 15:49
by jacky
admin wrote:Always at the beginning? Or anywhere? If anywhere, are multiple comments allowed?
no, classic regexp pattern, so it's anywhere and multiple comments are allowed yes. And make sure there's no backslash ( \ ) before, because if the parenthesis is escaped then it's not a comment, obviously!

BTW, I'm sure it's on your list already somewhere ;) but for RegExp rename some kind of preview would be great, to make sure we're not about to screw up all the names.
Even a simple "Test/Preview" button on the window, that would popup the results for selected List items would be nice. Or even only the focused one, just something to make sure.

Posted: 22 Aug 2007 15:58
by admin
jacky wrote:
admin wrote:Always at the beginning? Or anywhere? If anywhere, are multiple comments allowed?
no, classic regexp pattern, so it's anywhere and multiple comments are allowed yes. And make sure there's no backslash ( \ ) before, because if the parenthesis is escaped then it's not a comment, obviously!

BTW, I'm sure it's on your list already somewhere ;) but for RegExp rename some kind of preview would be great, to make sure we're not about to screw up all the names.
Even a simple "Test/Preview" button on the window, that would popup the results for selected List items would be nice. Or even only the focused one, just something to make sure.
You don't happen to have a RegExp handy that removes those comments? :wink: Looks like a typical RegExp job...

Yes, it's on my list. I'm aware of the importance. I just put "rename preview" on the roadmap to give it more gravity...

Posted: 22 Aug 2007 16:13
by jacky
admin wrote:You don't happen to have a RegExp handy that removes those comments? :wink: Looks like a typical RegExp job...
hehe... Well, that one would do it I think :

Code: Select all

(?<!\\)\(\?#.*?\)
but I don't think it's supported by the MS/VB engine, and I'm not sure how/if it could be done without lookbehinds so...
admin wrote:Yes, it's on my list. I'm aware of the importance. I just put "rename preview" on the roadmap to give it more gravity...
Makes me feel much better already ;)

Posted: 22 Aug 2007 16:13
by admin
jacky wrote:
admin wrote:Always at the beginning? Or anywhere? If anywhere, are multiple comments allowed?
no, classic regexp pattern, so it's anywhere and multiple comments are allowed yes. And make sure there's no backslash ( \ ) before, because if the parenthesis is escaped then it's not a comment, obviously!
Sure about the backslashes? No word about them here: http://www.regular-expressions.info/comments.html

Posted: 22 Aug 2007 16:17
by jacky
admin wrote:Sure about the backslashes? No word about them here: http://www.regular-expressions.info/comments.html
Yeah i'm sure, it's a common regexp thing that's why it's not mentioned here or everywhere. And I do use EditPadPro (same author as this website) every day and tested with it just to be sure ;)

It's mentioned here: http://www.regular-expressions.info/characters.html#qe

PS: EditPadPro is the best text editor out there. It's like the XY of text editors! 8)

Posted: 22 Aug 2007 18:07
by Muroph
jacky wrote:Of course it does, since you cannot be on a location not shown on Tree! As soon as you collapse a parent folder of your current location, you'll jump to that parent.

Same apply here, it's even hinted in the description: "Fully collapse the current drive (resp. \\Server, Desktop, MyDocuments) in Tree. Select and focus the drive root."
So this is how it works...
I havent noticed the end of the description.

Hmm...
Is there a way to collapse everything except the current location?
Because sometimes the tree gets really big and difficult to work with.
jacky wrote:BTW, I'm sure it's on your list already somewhere but for RegExp rename some kind of preview would be great, to make sure we're not about to screw up all the names.
Even a simple "Test/Preview" button on the window, that would popup the results for selected List items would be nice. Or even only the focused one, just something to make sure.
Yeah, this would be great!

And maybe add something like a 'favorite expressions' list, where you could have some patterns separated from the history of expressions.
This way it'd be easier to use common patterns, not having to search in the mess the history can be if you dont clean it often.

Posted: 23 Aug 2007 08:41
by admin
Muroph wrote:Is there a way to collapse everything except the current location?
Because sometimes the tree gets really big and difficult to work with.
Yes, it's called "Rebuild Tree" (Ctrl+Shift+F4).
Muroph wrote:And maybe add something like a 'favorite expressions' list, where you could have some patterns separated from the history of expressions.
This way it'd be easier to use common patterns, not having to search in the mess the history can be if you dont clean it often.
Yes, I heard this wish before. I see the point, but after all XY is not a file renamer. Other things are more important and will be done first...

Re: Regex comments not working

Posted: 23 Aug 2007 10:46
by admin
Muroph wrote:(?#ren 1st num)\D*(\d+).*(\.[0-9A-z]*$)>filename_$1$2

This should rename the file using the 1st sequence of numbers and the extension.
But it gives a syntax error message.
All regex with comments do.
The only way I found to avoid the error is to remove the comments.
The next BETA version will remove the comments for you. :)