# Regex handling: Mac vs. Win

**URL:** <https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706>\
**Category:** Mac\
**Created:** [January 1, 2022, 7:48pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706 "2022-01-01T19:48:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 1, 2022, 7:48pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/1 "2022-01-01T19:48:10Z")

</div>

I stumbled into interesting problem, where Regex used in Windows version does not work at all in Mac version.

Regex itself:

```auto
%ARTIST%$regexp(%TITLE%,'^(.+?)\s+[[({<]?\s*(?:featuring|feat\.?|ft\.?)\s*([^])}>]+)[])}>]?(.*)$',' feat. $2$3+++$1',1)

```

When applied to TITLE, via Convert -\> Tag - Tag:  
In Windows version, it works fine and produces expected output:  
`"Aphex Twin feat. XYZ+++Ageispolis"`

On Mac version, it produces:  
`Aphex TwinInvalid regular expression: ^(.+?)\s+[[({<]?\s*(?:featuring|feat\.?|ft\.?)\s*([^])}>]+)[])}>]?(.*)`$

Tag used for testing looks like this:  
TITLE: Ageispolis (feat. XYZ)  
ARTIST: Aphex Twin

For me it does look like, Mac version handles regex differently, but I (at least currently) don't quite understand how or why.

---

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 1, 2022, 10:14pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/2 "2022-01-01T22:14:31Z")

</div>

Ok apparently, it dislikes **s+** in that regex.  
Not sure though, why and how to fix this, as replacing + with {1,} does not seem to work either.

---

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 1, 2022, 10:28pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/3 "2022-01-01T22:28:35Z")

</div>

OK, looks like I managed to fix it, but still unsure why it does not work on MacOS.  
What I did, I simply removed highlighted square bracket (first one after \s+).

%ARTIST%$regexp(%TITLE%,'^(.+?)\s+**[**[({\<]?\s\*(?:featuring|feat.?|ft.?)\s\*([^])}\>]+)[])}\>]?(.\*)$',' feat. $2$3+++$1',1)

Now it works on both, Windows and MacOS.  
Interestingly, Windows version does not even seem to care, even if I add more square brackets and completely break "regex rules" 🤣

---

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 3, 2022, 6:37pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/4 "2022-01-03T18:37:30Z")

</div>

Another interesting thing seems to be, that on Mac `\l` matches escaped letter "l", instead of it acting as [Lowercase shorthand](https://www.regular-expressions.info/shorthand.html#more)

At the end of the day, it is quite confusing and maybe someone else can shed better light into 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:** [January 3, 2022, 6:49pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/5 "2022-01-03T18:49:38Z")

</div>

AFAIK the documentation on MP3tag for Mac states that for "[Replace with regular expressions](https://community.mp3tag.de/t/quick-actions-and-action-groups/51882)" a different syntax is used:

> [@Quick Actions and Action Groups](https://community.mp3tag.de/t/quick-actions-and-action-groups/51882/1):
>
> **Mp3tag for Mac** uses the [ICU regular expression engine](https://unicode-org.github.io/icu/userguide/strings/regexp.html). A good resource to test and experiment with regular expressions is [regex101](https://regex101.com/).

---

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 3, 2022, 6:50pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/6 "2022-01-03T18:50:57Z")

</div>

Thank you @ohrenkino, I already thought that I am loosing my mind 😃

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [January 3, 2022, 6:52pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/7 "2022-01-03T18:52:51Z")

</div>

> [@Etz](#):
>
> Regex itself:
> 
> ```auto
> %ARTIST%$regexp(%TITLE%,'^(.+?)\s+[[({<]?\s*(?:featuring|feat\.?|ft\.?)\s*([^])}>]+)[])}>]?(.*)
> 
> ```
> 
> When applied to TITLE, via Convert -\> Tag - Tag:,' feat. $2$3+++$1',1)
> 
> ```auto
> 
> When applied to TITLE, via Convert -> Tag - Tag:
> 
> ```

I’m not sure if this is your entire statement, but it looks like both the round and square brackets don’t have matching open/close states. Looks like you identified one square bracket condition, but I still think you have an extra closing round bracket as well.

---

<div class="post-metadata">

**Author:** ![Etz](https://community.mp3tag.de/user_avatar/community.mp3tag.de/etz/32/7648_2.png) [@Etz](https://community.mp3tag.de/u/Etz)\
**Post date:** [January 3, 2022, 6:54pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/8 "2022-01-03T18:54:23Z")

</div>

I believe you are right, but fun fact is that on Windows version it worked just fine in that state.  
I started to get errors after I migrated all my actions over to Mac version and I am currently in progress of rewriting and checking each one of them, as I have lots of regex related issues on Mac version at the moment.  
All of those worked fine on Windows version.

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [January 3, 2022, 7:01pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/9 "2022-01-03T19:01:27Z")

</div>

I’m sure there are many more “fun” differences you will find. This is par for the course between operating systems. But I think if you start by correcting the context of your statements they will work more effectively across all. There may be some conditions in Windows that this may not produce correct results.

---

<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 2, 2022, 7:02pm UTC](https://community.mp3tag.de/t/regex-handling-mac-vs-win/55706/10 "2022-02-02T19:02:06Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
