# Selecting terms between interchangeable (, \[, { brackets

**URL:** <https://community.mp3tag.de/t/selecting-terms-between-interchangeable-brackets/45953>\
**Category:** Support\
**Created:** [July 21, 2019, 5:19am UTC](https://community.mp3tag.de/t/selecting-terms-between-interchangeable-brackets/45953 "2019-07-21T05:19:46Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Crissov](https://community.mp3tag.de/user_avatar/community.mp3tag.de/crissov/32/6619_2.png) [@Crissov](https://community.mp3tag.de/u/Crissov)\
**Post date:** [July 21, 2019, 7:58am UTC](https://community.mp3tag.de/t/selecting-terms-between-interchangeable-brackets/45953/3 "2019-07-21T07:58:31Z")

</div>

You want to find conditionally matching brackets of three different types. That is either impossible or very verbose within a single regular expression.

If you wanted to find pairs of matching simple quotation marks `'` and `"`, that is possible in many engines: `(["'])[^"']*\1` or `("|').*?$1`, or some other combination of matching the start character, optionally advancing and then matching that start character as end character.

Your current start character is a left parenthesis `(` which needs to be escaped `\(` but is not yet in a matching group `(\()`. Likewise, your current end character is a right parenthesis `(\))`. You could add square brackets and curly braces to these groups: either `(\(\[\{)` and `(\)\]\})` or `([([{])` and `([)\[}])`. This would, however also match unequal pairs like `(]`, `{)` and `[}`. If that is good enough because you will never encounter nested brackets, your solution (with [non-capturing groups](https://regular-expressions.mobi/refcapture.html) – otherwise `$2` must become `$3`) could be:

```auto
$regexp(%title%,(.*)(?:[([{])(.*?[mM]ix|.*?[eE]dit|.*?[vV]ersion|.*?[aA]coustic)(?:[)\[}]),$1'['$2']')

```

[![image](https://community.mp3tag.de/uploads/default/original/2X/9/953a1819417a2993451e26e6bb7ff1668a7e0c67.png)](https://regexper.com/#%5E%28.*%29%28%3F%3A%5B%28%5B%7B%5D%29%28.*%3F%5BmM%5Dix%7C.*%3F%5BeE%5Ddit%7C.*%3F%5BvV%5Dersion%7C.*%3F%5BaA%5Dcoustic%29%28%3F%3A%5B%29%5C%5B%7D%5D%29%24)

PS: You had vertical bars `|` inside character classes `[aA]`, but they only separate alternatives as _or_ within groups `(a|A)`.

---

_[View the full topic](https://community.mp3tag.de/t/selecting-terms-between-interchangeable-brackets/45953)._
