Comment-out of entire regex search

Greetings. I’m experimenting with hoped-for improvements to some custom action groups I have which involve regular expressions, and I have one particular action in a group that I’d basically like to comment out — put the entire existing regex search expression into a (?#) comment in order to disable it from doing anything when the action group is run, at least temporarily, until I’ve verified that my changes to other actions in the group are doing what I expect. My current (working) action is this:

Action: Replace with regular expressions

Field: COMPOSERSORT

Regular expression: ^(.+?) \[music\]; (.+?) \[lyrics\]'$'

Replace matches with: \1, \2

I tried changing the regular expression to (?#^(.+?) \[music\]; (.+?) \[lyrics\]'$'), but when I click on the dialog’s OK button, MP3Tag displays the following message:

Regular expression: (?#^(.+?) \[music\]; (.+?) \[lyrics\]$)

Regular expression

Found a closing ) with no corresponding opening parenthesis.
 The error occurred while parsing the regular expression
fragment: '[lyrics\]$>>>HERE>>>)'.

I know there are other things I can do to get around that problem (make a copy of the entire action group and delete that action from the copy, etc.), but anybody know of a reason why commenting out the whole line should not work? (I’ve verified that (?#) comments do work, when I’m not trying to use it on the whole line.)

I would extract this regular expression to it's own Action Group and then just activate or deactivate it (with the help of the checkbox) easily in the Action Groups selection window.

I'm not sure if such an inline comment (?# comment ) is meant to work at all for entire regular expressions.

It’s not really a huge deal either way — I was mostly interested in learning about whatever limitations there might be for the (?#) comment method in MP3Tag — but thanks for the suggestion.

According to @Florian's latest information about the used Boost.Regex, such a comment

image
should be valid, but I also get the same error for
(?#^(.+?) \[music\]; (.+?) \[lyrics\]$)
as you:

image

If I suppress the last closing brace this regular expression can be saved.
As I don't know what exactly you like to achieve with it, I can't test it.

The problem is that the first opening parentheses is treated as part of the comment, making the whole expression imbalanced.

If you want to comment out the whole expression, using

(?# expression

should work. For real comments (without any parentheses that are part of the expression), the correct syntax is

(?# comment )expression

1 Like

Confirmed, works here. Thanks much.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.