# $escregexp

**URL:** https://community.mp3tag.de/t/escregexp/8739
**Category:** General Discussion
**Created:** [August 8, 2009, 12:33pm UTC](https://community.mp3tag.de/t/escregexp/8739 "2009-08-08T12:33:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 8, 2009, 12:33pm UTC](https://community.mp3tag.de/t/escregexp/8739/1 "2009-08-08T12:33:37Z")

</div>

Please add the scripting function

$escregexp(string) escape all special characters in string, making a literal regular expression

Meanwhile one may use

$regexp(.|\*?+(){}'['']'^$,'([.|\*?+(){}[]^$])',\\1)

e.g.

$regexp(A$A,'['$regexp(.|\*?+(){}'['']'^$,'([.|\*?+(){}[]^$])',\\1)']',S)

---

<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 9, 2009, 12:33pm UTC](https://community.mp3tag.de/t/escregexp/8739/2 "2009-08-09T12:33:39Z")

</div>

One may use the following to get the same escaping effect ...

```
$regexp(A$A,'[$replace('.|*?+(){}[]^$',.,\.,|,\|,*,\*,?,\?,+,\+,(,\(,),\),{,\{,},\},'[','\[',']','\]',^,\^,$,\$)]',S)
which gives "ASA".

```

... or completely literalized ...

**$regexp('A$A', '['$replace('.|\*?+(){}[]^$', '.','\.','|','\|','\*','\*','?','\?','+','\+','(','\(',')','\)', '{','\{','}','\}','[','\[',']','\]','^','\^','$','\$')']','S')**

... or ...

**$regexp('A$A','['$regexp('.|\*?+(){}[]^$','([].|\*?+(){}$^[])','\\\1')']','S')**

DD.20090809.1633.CEST, DD.20150227.1716.CET

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 9, 2009, 12:58pm UTC](https://community.mp3tag.de/t/escregexp/8739/3 "2009-08-09T12:58:55Z")

</div>

I was seeking a less not more verbose alternative, Detlev 🙂

Do your alternatives have an advantage over the original?

---

<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 9, 2009, 1:11pm UTC](https://community.mp3tag.de/t/escregexp/8739/4 "2009-08-09T13:11:39Z")

</div>

> [@chrisjj](#):
>
> I was seeking a less not more verbose alternative, Detlev 🙂 Do your alternatives have an advantage over the original?

... hmm, it needs no regexp machine, but only internally string manipulations, so it could be executed some ticks quicker, I think so, and it is better to read and understand for no-regex-people.

DD.20090809.1710.CEST

---

<div class="post-metadata">

### Author: ![chrisjj](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/a698b9/32.png) [@chrisjj](https://community.mp3tag.de/u/chrisjj)
#### Post date: [August 9, 2009, 2:14pm UTC](https://community.mp3tag.de/t/escregexp/8739/5 "2009-08-09T14:14:39Z")

</div>

I see. Thanks.
