# Escaping in scripting

**URL:** <https://community.mp3tag.de/t/escaping-in-scripting/52492>\
**Category:** Support\
**Created:** [March 24, 2021, 1:01am UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492 "2021-03-24T01:01:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![R.J](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@R.J](https://community.mp3tag.de/u/R.J)\
**Post date:** [March 24, 2021, 1:01am UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/1 "2021-03-24T01:01:56Z")

</div>

I have several files with an artist tah of _LastName, FirstName's Big Band_ (or Trio, etc.). Sometimes it's _LastName, FirstName MiddleName's Big Band_.

I want to reverse First and Last Names, leaving the _'s_ in place.

So I tried to replace artist with $regexp(%artist%,'^(\S+),\s+(._)?(\*\*'\*\*s ._)$',$2 $1$3)

How do I escape the single-quote before the s?

When I got tried things that resulted in a valid regexp, it put the single-quote in $2 rather than $3 like I expected. I finally came up with something that worked but I'd like to know for the future what I'm doing wrong

---

<div class="post-metadata">

**Author:** ![R.J](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@R.J](https://community.mp3tag.de/u/R.J)\
**Post date:** [March 24, 2021, 1:03am UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/2 "2021-03-24T01:03:51Z")

</div>

Also, why didn't the double-asterisks in the previous message bold the single-quote?

Removing them:

$regexp(%artist%,'^(\S+),\s+(._)?('s ._ )$',$2 $1$3)

---

<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:** [March 24, 2021, 5:24am UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/3 "2021-03-24T05:24:53Z")

</div>

> [@R.J](#):
>
> How do I escape the single-quote

You need 2 of them.: `''`  
See also the [help on export](https://docs.mp3tag.de/export)

---

<div class="post-metadata">

**Author:** ![R.J](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@R.J](https://community.mp3tag.de/u/R.J)\
**Post date:** [March 24, 2021, 9:38pm UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/4 "2021-03-24T21:38:06Z")

</div>

That's the way I got the single-quote as part of $2 instead of $3 where it should be according to the parentheses

---

<div class="post-metadata">

**Author:** ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)\
**Post date:** [March 24, 2021, 9:54pm UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/5 "2021-03-24T21:54:13Z")

</div>

You can try `$regexp(%artist%,'^(\S+),\s+(.*)?(''''s.*)'$,$2 $1$3)`

It's really a special case and I'm not arguing that this is very straight-forward 🙂

> By the way: Can you edit your post to enclose the format string in backticks ```, e.g., ``my format string`` so that spaces and other special characters are preserved?

---

<div class="post-metadata">

**Author:** ![R.J](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@R.J](https://community.mp3tag.de/u/R.J)\
**Post date:** [March 25, 2021, 3:55am UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/6 "2021-03-25T03:55:39Z")

</div>

That looks like it works. It gives me something else to try. Thanks

---

<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:29pm UTC](https://community.mp3tag.de/t/escaping-in-scripting/52492/7 "2026-02-09T12:29:08Z")

</div>


