# If a pattern exists in a string, then take a certain action on another string

**URL:** <https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635>\
**Category:** Support\
**Created:** [October 30, 2020, 2:34pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635 "2020-10-30T14:34:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev91618](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dev91618](https://community.mp3tag.de/u/dev91618)\
**Post date:** [October 30, 2020, 2:34pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635/1 "2020-10-30T14:34:39Z")

</div>

Hello all, good day. Thanks for all your help thus far. I have yet another question.

If in a string say %album%, a string 'Vol 7' exists, I want to replace the track with 7%track%, else no action.

How can this conditional formatting be done?

Truly appreciate your help.

Thanks.

---

<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 30, 2020, 2:51pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635/2 "2020-10-30T14:51:18Z")

</div>

You could try an action of the type "Format value" for TRACK  
Format string: `$regexp(%album%,.*Vol (\d+),$1)%track%`

---

<div class="post-metadata">

**Author:** ![dev91618](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@dev91618](https://community.mp3tag.de/u/dev91618)\
**Post date:** [October 30, 2020, 8:19pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635/3 "2020-10-30T20:19:41Z")

</div>

Hello. Thanks. And what if my logic is  
If  
Vol number exists,  
thenVol = Discnumber,  
else discnumber =1

Appreciate your 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 30, 2020, 8:25pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635/4 "2020-10-30T20:25:02Z")

</div>

A little hard to tell as you supply so little information around it. But it could go along something like`"Format value" for DISCNUMBER

Format string: `$if2($regexp(%album%,.*Vol (\d+),$1),1)`

---

<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:** [February 9, 2026, 12:28pm UTC](https://community.mp3tag.de/t/if-a-pattern-exists-in-a-string-then-take-a-certain-action-on-another-string/50635/5 "2026-02-09T12:28:54Z")

</div>


