Escaping commas in regular expressions

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')

for the comma:

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

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

Awesome, thanks!

',' is fine. Backslash is not needed.

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


1 Like