# Execute regular expression only if brackets present

**URL:** https://community.mp3tag.de/t/execute-regular-expression-only-if-brackets-present/68639
**Category:** Support
**Created:** [May 28, 2025, 12:24pm UTC](https://community.mp3tag.de/t/execute-regular-expression-only-if-brackets-present/68639 "2025-05-28T12:24:54Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Casual\_Tea](https://community.mp3tag.de/user_avatar/community.mp3tag.de/casual_tea/32/18886_2.png) [@Casual\_Tea](https://community.mp3tag.de/u/Casual_Tea)
#### Post date: [May 29, 2025, 3:14pm UTC](https://community.mp3tag.de/t/execute-regular-expression-only-if-brackets-present/68639/6 "2025-05-29T15:14:44Z")

</div>

> [@viviancels](#):
>
> But how to set the condition that the action is performed only if there are brackets with the performer in title.

You can do this by using the regex twice in your action. First to check if the match is not equal to the field that you match on (brackets are present) and then to perform the actual replacement that you wish to perform if they are not equal. If they are equal, the current content of the field is retained. This works because the regex returns the field it is matched against in the case that no match was found by default.

It's quite wordy and I really wish there was a simple way to say: Abort the action/change nothing if the regex does not match.

I have described the problem and the workaround I'm using [in this thread](https://community.mp3tag.de/t/simple-way-to-abort-action-if-regex-does-not-match/66243).

Here's my latest example of this workaround:  
Action type: Format value  
Field:

```auto
MUSICBRAINZ_ALBUMTYPE

```

Format string:

```auto
$if($neql($regexp(%ALBUM%,.* \'['EP\']'.*,EP,0),%ALBUM%),$regexp(%ALBUM%,.* \'['EP\']'.*,EP,0),$meta_sep(MUSICBRAINZ_ALBUMTYPE,\\))

```

This action checks if `ALBUM` contains ` [EP]` and sets the `MUSICBRAINZ_ALBUMTYPE` to `EP` if it does. If `ALBUM` does not contain ` [EP]`, the release type is set to its current value(s).

---

_[View the full topic](https://community.mp3tag.de/t/execute-regular-expression-only-if-brackets-present/68639)._
