Regex comments not working

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Regex comments not working

Post 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?

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regex comments not working

Post 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.

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Post 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.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post 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."
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post 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 ")" ??

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post 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)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post 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?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post 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.
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post 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...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post 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 ;)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post 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

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post 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)
Proud XYplorer Fanatic

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Post 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.

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post 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...

admin
Site Admin
Posts: 66431
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regex comments not working

Post 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. :)

Post Reply