# Escaping commas in regular expressions

**URL:** <https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565>\
**Category:** Support\
**Created:** [February 9, 2011, 6:30pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565 "2011-02-09T18:30:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![IMGrant](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/i/a183cd/32.png) [@IMGrant](https://community.mp3tag.de/u/IMGrant)\
**Post date:** [February 9, 2011, 6:30pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/1 "2011-02-09T18:30:35Z")

</div>

I want to use a comma in my regular expression, so I tried this:

$regexp($meta(artist),^(._), (._)$,$1, and $2)

It supposed to take multiple artist fields and produce something like 'Artist 1, Artist 2, and Artist 3'

But I get the following error:

REGEXP ERROR: Regular expression  
Escape sequence terminated prematurely. The error occured while parsing the regular expression: '^(.\*)\>\>\>HERE\>\>\>'.

What am I doing wrong...?

(P.S. A teeny bug: it really does say 'occured', but it should say 'occurred')

---

<div class="post-metadata">

**Author:** ![pone](https://community.mp3tag.de/user_avatar/community.mp3tag.de/pone/32/272_2.png) [@pone](https://community.mp3tag.de/u/pone)\
**Post date:** [February 9, 2011, 6:45pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/2 "2011-02-09T18:45:00Z")

</div>

for the comma:  
','

your string:  
$regexp($meta(artist),^(._)',' (._)$,$1',' and $2)

your string without comma before the "and":  
$regexp($meta(artist),^(._)',' (._)$,$1 and $2)

---

<div class="post-metadata">

**Author:** ![IMGrant](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/i/a183cd/32.png) [@IMGrant](https://community.mp3tag.de/u/IMGrant)\
**Post date:** [February 9, 2011, 7:22pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/3 "2011-02-09T19:22:20Z")

</div>

Awesome, thanks!

---

<div class="post-metadata">

**Author:** ![dano](https://community.mp3tag.de/user_avatar/community.mp3tag.de/dano/32/6_2.png) [@dano](https://community.mp3tag.de/u/dano)\
**Post date:** [February 9, 2011, 7:28pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/4 "2011-02-09T19:28:00Z")

</div>

',' is fine. Backslash is not needed.

---

<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:** [August 29, 2014, 5:06pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/5 "2014-08-29T17:06:07Z")

</div>

> [@IMGrant](#):
>
> I want to use a comma in my regular expression ... But I get the following error ...

There is no problem when the regexp parameters have been 'literalized', that means, enclosed in single apostrophes.

**$regexp($meta(artist),'^(.\*), (.\*)$','$1 and $2') From: Artist 1, Artist 2 To: Artist 1 and Artist 2 From: Artist 1, Artist 2, Artist 3 To: Artist 1, Artist 2 and Artist 3**

DD.20140829.2106.CEST

---

<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:22pm UTC](https://community.mp3tag.de/t/escaping-commas-in-regular-expressions/11565/6 "2026-02-09T12:22:53Z")

</div>

Closed on February 9, 2026, 12:22pm UTC


