# Error with format regexp compared to regular replace with regular expression

**URL:** <https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775>\
**Category:** Support\
**Created:** [February 6, 2018, 11:37am UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775 "2018-02-06T11:37:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 11:37am UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/1 "2018-02-06T11:37:53Z")

</div>

The below works with the replace with reg exp action:

```
Replace: ([^\s,]+)
Replace With: [url="https://urlhere=$1"]$1[/url]

```

But this doesn't in the format regexp function.

```
$regexp(%artist%,([^\s,]+?),[url="https://urlhere=$1"]$1[/url])

```

It returns an error:

```
  "REGEXP ERROR: Regular expression

Invalid preceding regular expression prior to repetition operator. The error occurred while parsing the regular expression: '(+?>>>HERE>>>)'."

```

Is this a bug?

I cannot use ' between ([^\s,]+) as it leads to unwanted results. And I need the $regexp fn as it's for use in an export file.

Basically what I want is:

String is:

```
test1, test2, test3

```

Output:

```
[url=https://urlhere=test1]test1[/url], [url=https://urlhere=test2]test2[/url], [url=https://urlhere=test3]test3[/url]

```

My brain is not functioning properly today and can't figure it out. Cheers.

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 12:09pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/2 "2018-02-06T12:09:03Z")

</div>

Think I got it.

**works**

```
$regexp(%artist%,'([^,]+[^\s]+)',aaa$1bbb)

```

**doesn't**

```
$regexp(%artist%,'([^,\s]+)',aaa$1bbb)

```

Possibly a bug, I don't know.

**Nope still not working when the artist is.**

```
test1, test2, test3

```

Only works with as artist  
test1

---

<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:** [February 6, 2018, 12:23pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/3 "2018-02-06T12:23:42Z")

</div>

> [@stevehero](#):
>
> ... Invalid preceding regular expression prior to repetition operator. ...

Trying to understand ...

`'#'$regexp('test1, test2, test3','([^\s,]+?)','x')'#'`  
==\>  
`'#xxxxx, xxxxx, xxxxx#'`

... where is the problem?

DD.20180206.1423.CET

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 12:32pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/4 "2018-02-06T12:32:57Z")

</div>

Thanks.

> [@DetlevD](#):
>
> Trying to understand ...

Example from 1st post modified below for clearer understanding:

Artist string is:

```
artist1, artist2, artist3

```

Required output of artist to export script:

```
[url=https://urlhere=artist1]artist1[/url], [url=https://urlhere=artist2]artist2[/url], [url=https://urlhere=artist3]artist3[/url]

```

Notice each of the artists 1, 2 & 3 are used twice for the URL and the text display.

---

<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:** [February 6, 2018, 1:20pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/5 "2018-02-06T13:20:05Z")

</div>

```auto
$regexp('test1, test2, test3','(\w+)(,?)','[url="https://urlhere=$1"]$1[/url]$2')
==>
[url="https://urlhere=test1"]test1[/url], [url="https://urlhere=test2"]test2[/url], [url="https://urlhere=test3"]test3[/url]

```

DD.20180206.1520.CET

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 1:27pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/6 "2018-02-06T13:27:42Z")

</div>

[quote="DetlevD, post: 5, topic:19775"] ``` $regexp('test1, test2, test3','(\w+)(,?)','[$1](https://urlhere=$1)$2')  
==\>  
[test1](https://urlhere=test1), [test2](https://urlhere=test2), [test3](https://urlhere=test3)

```auto
[/quote]
I can do that with my non-working version.

If you try this it doesn't work with artists with more than one word. Sorry for not giving that example.

Try Artist string:

    This Artist1, This Artist2, This Artist3

That's why I was trying the don't match `,\s` to alleviate any problems but it appears the $regpexp fn is written differently than the replace with regular expression action as the $regexp one fails where the action does not.
```

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 1:55pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/7 "2018-02-06T13:55:11Z")

</div>

**Got a working version:**

Seems hacky but it works:

```
$regexp('This Artist 1, This Artist 2, This Artist 3','\s*([^\,]+[^,\s])','[url="https://urlhere=$1"]$1[/url]')

```

resulted in: **notice no space between ,**

```
[url="https://urlhere=This Artist 1"]This Artist 1[/url],[url="https://urlhere=This Artist 2"]This Artist 2[/url],[url="https://urlhere=This Artist 3"]This Artist 3[/url]

```

EDIT:

```
$trim($regexp('This Artist 1, This Artist 2, This Artist 3','(,*)\s*([^\,]+[^,\s])','$1 [url="https://urlhere=$2"]$2[/url]'))

```

RESULTS:  
[This Artist 1](https://urlhere=This%20Artist%201), [This Artist 2](https://urlhere=This%20Artist%202), [This Artist 3](https://urlhere=This%20Artist%203)

---

<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:** [February 6, 2018, 2:30pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/8 "2018-02-06T14:30:59Z")

</div>

> [@stevehero](#):
>
> **Got a working version:**

Yes, that's looking good and works ok. Thank you.

DD.20180206.1630.CET

---

<div class="post-metadata">

**Author:** ![stevehero](https://community.mp3tag.de/user_avatar/community.mp3tag.de/stevehero/32/337_2.png) [@stevehero](https://community.mp3tag.de/u/stevehero)\
**Post date:** [February 6, 2018, 2:43pm UTC](https://community.mp3tag.de/t/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/9 "2018-02-06T14:43:48Z")

</div>

> [@DetlevD](#):
>
> Yes, that's looking good and works ok...

No probs.

I still maintain there might be something wrong in the $regexp fn. Maybe not. Glad there's a solution.

---

<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/error-with-format-regexp-compared-to-regular-replace-with-regular-expression/19775/10 "2026-02-09T12:27:13Z")

</div>


