# Help with regex and logic in export options

**URL:** https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502
**Category:** Export
**Created:** [October 16, 2020, 6:33pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502 "2020-10-16T18:33:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![henriquebs12](https://community.mp3tag.de/user_avatar/community.mp3tag.de/henriquebs12/32/8205_2.png) [@henriquebs12](https://community.mp3tag.de/u/henriquebs12)
#### Post date: [October 16, 2020, 6:33pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502/1 "2020-10-16T18:33:39Z")

</div>

I'm setting an export script to fill a specific html model that will be used later. I want to make 3 conditionals.

1. If the %album% tag doesn't contain the string " - EP" or " - Single", add " [Album]" and write "%album% [Album]"

2. If the %album% tag contains the string " - EP", replaces " - EP" with " [EP]" and write the edited album field.

3. If the %album% tag contains the string " - Single", replaces " - Single" with " [Single]" and write the edited album field.

I started doing a pseudo code and building the code right after, but I'm struggling to understand how MP3Tag logic works:

```
<div>
$if( %album% has string " - EP" || " - Single", Do nothing, Concatenate and write %album% + [ALBUM] )
$if( %album% has string " - EP", Write $replace(%album%, - EP, [EP]), Do nothing )
$if( %album% has string " - Single", Write $replace(%album%, - Single, [Single]), Do nothing )
</div>

```

I could't move forward. Can somebody help?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 16, 2020, 6:53pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502/2 "2020-10-16T18:53:30Z")

</div>

You can setup a number or search/replace pairs in just one statement:, e.g.  
`$replace(%album%, - EP, '[Album]', - Single, '[Album]',- EP,'[EP]',- Single,'[Single]')`

---

<div class="post-metadata">

### Author: ![henriquebs12](https://community.mp3tag.de/user_avatar/community.mp3tag.de/henriquebs12/32/8205_2.png) [@henriquebs12](https://community.mp3tag.de/u/henriquebs12)
#### Post date: [October 16, 2020, 6:58pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502/3 "2020-10-16T18:58:04Z")

</div>

Hi ohrenkino, thanks for your help. I tried here and it works for EPs and Singles. But how to add "[Album]" if there is not "EP" or "Single" on it?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [October 16, 2020, 7:15pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502/4 "2020-10-16T19:15:25Z")

</div>

What about a brute force approach?  
`$replace(%album% '[Album]',' - EP [Album]','[EP]','- Single [Album]','[Single]')`  
You simply add the [Album] to every album and then you replace the special string plus the added [Album] with just the special string.

---

<div class="post-metadata">

### Author: ![henriquebs12](https://community.mp3tag.de/user_avatar/community.mp3tag.de/henriquebs12/32/8205_2.png) [@henriquebs12](https://community.mp3tag.de/u/henriquebs12)
#### Post date: [October 16, 2020, 7:21pm UTC](https://community.mp3tag.de/t/help-with-regex-and-logic-in-export-options/50502/5 "2020-10-16T19:21:00Z")

</div>

Nice and smart approach. It worked like expected. Thank you very much for the help!
