# Comment-out of entire regex search

**URL:** https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104
**Category:** Support
**Created:** [September 12, 2023, 2:12am UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104 "2023-09-12T02:12:45Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mazeckenrode](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@mazeckenrode](https://community.mp3tag.de/u/mazeckenrode)
#### Post date: [September 12, 2023, 2:12am UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/1 "2023-09-12T02:12:45Z")

</div>

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:

```auto
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.)

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [September 12, 2023, 6:00am UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/2 "2023-09-12T06:00:19Z")

</div>

> [@mazeckenrode](#):
>
> 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.),

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.

> [@mazeckenrode](#):
>
> but anybody know of a reason why commenting out the whole line should not work?

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

---

<div class="post-metadata">

### Author: ![mazeckenrode](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@mazeckenrode](https://community.mp3tag.de/u/mazeckenrode)
#### Post date: [September 12, 2023, 12:48pm UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/3 "2023-09-12T12:48:28Z")

</div>

> [@LyricsLover](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [September 12, 2023, 1:21pm UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/4 "2023-09-12T13:21:47Z")

</div>

According to @Florian's [latest information](https://community.mp3tag.de/t/which-regular-expression-engine-and-syntax-is-used-by-mp3tag/47713/8) about the used Boost.Regex, such a comment

![image](https://community.mp3tag.de/uploads/default/original/2X/8/8d81fbca96b7730d759ec686283aa0fac5c8d0b1.png)  
[should be valid](https://www.boost.org/doc/libs/1_83_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html#boost_regex.syntax.perl_syntax.comments), but I also get the same error for  
`(?#^(.+?) \[music\]; (.+?) \[lyrics\]$)`  
as you:

![image](https://community.mp3tag.de/uploads/default/original/2X/a/aca83597b6ea5e4b05eb2762d644ad189f2e5a13.png)

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.

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [September 12, 2023, 1:28pm UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/5 "2023-09-12T13:28:38Z")

</div>

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`

---

<div class="post-metadata">

### Author: ![mazeckenrode](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@mazeckenrode](https://community.mp3tag.de/u/mazeckenrode)
#### Post date: [September 13, 2023, 2:15am UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/6 "2023-09-13T02:15:16Z")

</div>

> [@Florian](#):
>
> `(?# expression`
> 
> should work

Confirmed, works here. Thanks much.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [October 13, 2023, 2:16am UTC](https://community.mp3tag.de/t/comment-out-of-entire-regex-search/62104/7 "2023-10-13T02:16:12Z")

</div>

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