# If/Then logic to match pattern in a string?

**URL:** <https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592>\
**Category:** Support\
**Created:** [December 10, 2017, 2:22am UTC](https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592 "2017-12-10T02:22:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPThomas](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/9e8a1a/32.png) [@JPThomas](https://community.mp3tag.de/u/JPThomas)\
**Post date:** [December 10, 2017, 2:22am UTC](https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592/1 "2017-12-10T02:22:34Z")

</div>

Hello,

I'm trying to determine if it's possible to use regex if/then logic to analyze a string in a field, and do "A" if a pattern is found, and "B" if it's not.

In plain English, I'm trying to parse the ArtistSort field, and for artists with the string "The" at the beginning of the name, I want to remove the string "The". For names without "The" at the beginning, I want to do something else.

I think I could probably accomplish this with some kind of hack involving multiple actions, but I'd love to know if one action could do this for me.

What I've been finding information on seems to be more along the lines of "If field A exists, do 'X'", rather than matching patterns within a given field.

Thanks in advance for any guidance,

JPT

---

<div class="post-metadata">

**Author:** ![DetlevD](https://community.mp3tag.de/user_avatar/community.mp3tag.de/detlevd/32/123_2.png) [@DetlevD](https://community.mp3tag.de/u/DetlevD)\
**Post date:** [December 10, 2017, 10:30am UTC](https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592/2 "2017-12-10T10:30:14Z")

</div>

> [@JP Thomas](#):
>
> ... I'm trying to parse the ArtistSort field, and for artists with the string "The" at the beginning of the name, I want to remove the string "The". For names without "The" at the beginning, I want to do something else. ...

In Mp3tag listview I have defined a column:

Name: ArtistSort

Value: $regexp(%ARTIST%,'^(The|A)\s',,1)  
Field: %ARTISTSORT%  
Sort by: $regexp(%ARTIST%,'^(The|A)\s',,1)

 

DD.20171210.1230.CET

---

<div class="post-metadata">

**Author:** ![JPThomas](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/j/9e8a1a/32.png) [@JPThomas](https://community.mp3tag.de/u/JPThomas)\
**Post date:** [December 10, 2017, 6:06pm UTC](https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592/3 "2017-12-10T18:06:50Z")

</div>

Thanks much for your reply. This gives me something to explore.

All best,

JPT

> [@DetlevD](#):
>
> In Mp3tag listview I have defined a column:
> 
> Name: ArtistSort
> 
> Value: $regexp(%ARTIST%,'^(The|A)\s',,1)  
> Field: %ARTISTSORT%  
> Sort by: $regexp(%ARTIST%,'^(The|A)\s',,1)
> 
>  
> 
> DD.20171210.1230.CET

---

<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:27pm UTC](https://community.mp3tag.de/t/if-then-logic-to-match-pattern-in-a-string/19592/4 "2026-02-09T12:27:07Z")

</div>


