# Escape Quote in RegExp

**URL:** <https://community.mp3tag.de/t/escape-quote-in-regexp/48159>\
**Category:** Support\
**Created:** [March 15, 2020, 8:39am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159 "2020-03-15T08:39:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fastj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/7c8e57/32.png) [@fastj](https://community.mp3tag.de/u/fastj)\
**Post date:** [March 15, 2020, 8:39am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/1 "2020-03-15T08:39:14Z")

</div>

How do I escape a single quote in regexp? These attempts don't work:

```
$regexp(%title%, '[_#\']',)
$regexp(%title%, '[_#'']',)
```

---

<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 15, 2020, 9:01am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/2 "2020-03-15T09:01:28Z")

</div>

> [@fastj](#):
>
> $regexp(%title%, '[\_#'']',)

In this case it would probably be  
`$regexp(%title%, '[\_#''']',)  
It is 2 apostrophes to escape one and then you have 2 strings in apostrophes, one to the left and one to the right of the escaped character.

---

<div class="post-metadata">

**Author:** ![fastj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/7c8e57/32.png) [@fastj](https://community.mp3tag.de/u/fastj)\
**Post date:** [March 15, 2020, 11:08pm UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/3 "2020-03-15T23:08:48Z")

</div>

I copied and pasted that into the column value:

`$regexp(%title%, '[_#''']',)`

The column shows this:

`[SYNTAX ERROR IN FORMATTING STRING]`

---

<div class="post-metadata">

**Author:** ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)\
**Post date:** [March 15, 2020, 11:44pm UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/4 "2020-03-15T23:44:12Z")

</div>

Try this:  
`$regexp(%title%,'['_#''']',)`

---

<div class="post-metadata">

**Author:** ![fastj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/f/7c8e57/32.png) [@fastj](https://community.mp3tag.de/u/fastj)\
**Post date:** [March 16, 2020, 12:01am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/5 "2020-03-16T00:01:01Z")

</div>

That works! Thanks! Can you explain how/why that works?

---

<div class="post-metadata">

**Author:** ![ryerman](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ryerman/32/5285_2.png) [@ryerman](https://community.mp3tag.de/u/ryerman)\
**Post date:** [March 16, 2020, 4:22am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/6 "2020-03-16T04:22:40Z")

</div>

See "Characters with special functionality" here: [Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting)

---

<div class="post-metadata">

**Author:** ![Crissov](https://community.mp3tag.de/user_avatar/community.mp3tag.de/crissov/32/6619_2.png) [@Crissov](https://community.mp3tag.de/u/Crissov)\
**Post date:** [March 16, 2020, 11:08am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/7 "2020-03-16T11:08:57Z")

</div>

- `'['_#''']'`
  1. `[`
  2. `_#`
  3. `'`
  4. `]`

- `'[_#''']'`
  1. `[_#`
  2. `'`
  3. `]`, followed by an unmatched apostrophe

- `'[_#'']'`
  1. `[_#`
  2. `]`

---

<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:** [April 15, 2020, 11:08am UTC](https://community.mp3tag.de/t/escape-quote-in-regexp/48159/8 "2020-04-15T11:08:58Z")

</div>

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