# Scripting, a request and a question

**URL:** <https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614>\
**Category:** Support\
**Created:** [October 1, 2019, 5:00pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614 "2019-10-01T17:00:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daddy-o](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Daddy-o](https://community.mp3tag.de/u/Daddy-o)\
**Post date:** [October 1, 2019, 5:00pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/1 "2019-10-01T17:00:04Z")

</div>

Request: I've read the Mp3tag Help - Scripting Functions and have some limited regex experience. But some of the solutions I see posted demonstrate ability far beyond the Help resources. **What regex implementation (perl? sed?) would be most helpful to refer to when trying to build `replace,` etc., queries?** _It was great when I saw a nested query/replace along the way in my searches._

Question: I'm trying to remove everything non-alphanumeric from a file name to deal with a certain car's CD player display (and play) limitations. `$replace(%artist%,'The ',, ,,-,,.,,';',,\'&',,)` didn't quite work out. (I realize that certain `replace` may not meet syntax canon. It was the last of several stabs and by then I'd decided to place the request for a study guide that started this topic. _Thanks for dynamic preview!_)  
And what's the escape character? (the character, not the concept.)

I've brought it to a "good enough" level, but there's always next time. TIA

---

<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:** [October 1, 2019, 5:09pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/2 "2019-10-01T17:09:49Z")

</div>

It is said to be mainly a

> [@Daddy-o](#):
>
> perl

flavour.  
`$replace` is no regular expression but just a simple replace that replaces text constants and not patterns as regular expressions.  
You can test almost any scripting function with Convert\>Tag-Tag.

> [@Daddy-o](#):
>
> And what's the escape character?

it is the backslash `\` is the escape character.  
You only need it in regular expressions but not in plain replace functions.  
So

> [@Daddy-o](#):
>
> `,,\'&',`

is probably a little over the top and a plain `&` would be enough.

---

<div class="post-metadata">

**Author:** ![Daddy-o](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Daddy-o](https://community.mp3tag.de/u/Daddy-o)\
**Post date:** [October 1, 2019, 5:11pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/3 "2019-10-01T17:11:40Z")

</div>

Thanks for the background, I'll keep trying

---

<div class="post-metadata">

**Author:** ![Daddy-o](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Daddy-o](https://community.mp3tag.de/u/Daddy-o)\
**Post date:** [October 1, 2019, 5:16pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/4 "2019-10-01T17:16:27Z")

</div>

So in the middle of a replacement string does ,,,,x,y, replace a comma with nothing and x with y?  
Or would that be ,,,,x,y,  
(there are commas in the tags I want to use to rename the files, that's what started this) TIA

---

<div class="post-metadata">

**Author:** ![Daddy-o](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/3bc359/32.png) [@Daddy-o](https://community.mp3tag.de/u/Daddy-o)\
**Post date:** [October 1, 2019, 5:19pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/5 "2019-10-01T17:19:41Z")

</div>

Sorry, but the literal backslash was not in the posted text.  
So in the middle of a replacement string does ,backslash,,,x,y, replace a comma with nothing and x with y?  
Or would that be ,,,,x,y,

The forum software is giving me feedback for so many replies, I think this should do it.

---

<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:** [October 1, 2019, 5:28pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/6 "2019-10-01T17:28:13Z")

</div>

To replace a comma with the $replace() function use such a syntax:  
`$replace(%title%,',',)`  
the comma is enclosed in apostrophes (which would be the escape character here)

---

<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:** [October 31, 2019, 5:28pm UTC](https://community.mp3tag.de/t/scripting-a-request-and-a-question/46614/7 "2019-10-31T17:28:20Z")

</div>

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