# Literalized Expression Containing a Single Apostrophe

**URL:** https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547
**Category:** Support
**Created:** [January 29, 2015, 1:31pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547 "2015-01-29T13:31:13Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [January 29, 2015, 1:31pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/1 "2015-01-29T13:31:13Z")

</div>

In an ACTION FORMAT Title expression I want to replace a single apostrophe.  
a'c -\> abc

As a temporary fix I use FORMAT TITLE $regexp(%title%,'a.c',abc) but would prefer to directly search for the single apostrophe.

This is obviously a simplified example ... I do need to literalize the match.

Thanks

---

<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: [January 29, 2015, 2:36pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/2 "2015-01-29T14:36:38Z")

</div>

> [@rko31415](#):
>
> In an ACTION FORMAT Title expression I want to replace a single apostrophe ... a'c -\> abc ...

In Mp3tag the single apostrophe has the special meaning to be the string delimiter character.  
If you need the single apostrohe in a string as a literal character, it must be written twice (see Mp3tag manual).

From "a'c" to "abc" ...

**$replace('a''''c','','b')**

... or...

**$replace(a''c,'',b)**

...or ...

**$regexp('a''''c','a\x27c','abc')**

... or...

**$regexp('a''''c','\x27','b')**

.. or ...

**$replace('a''''c',$char(39),'b')**

DD.20150129.1658.CET

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [January 29, 2015, 7:09pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/3 "2015-01-29T19:09:17Z")

</div>

Thanks for the prompt response but your suggestions do not work with the FORMAT statement.  
I've tried the following:

FORMAT title $regexp(%title%,'a''''c',abc)  
FORMAT title $regexp(%title%,'a''c',abc)  
FORMAT title $regexp(%title%,''a'c'',abc)  
FORMAT title $regexp(%title%,'''a'c''',abc)  
FORMAT title $regexp(%title%,''a''c'',abc)  
FORMAT title $regexp(%title%,'''a''c''',abc)  
FORMAT title $regexp(%title%,''a'''c'',abc)  
FORMAT title $regexp(%title%,'''a'''c''',abc)  
FORMAT title $regexp(%title%,''a''''c'',abc)  
FORMAT title $regexp(%title%,'''a''''c''',abc)

Obviously I must have too much time on my hands.

Any other suggestions?  
Keith

---

<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: [January 29, 2015, 7:23pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/4 "2015-01-29T19:23:53Z")

</div>

Isn't it easiest that if you replace one string constant (here: apostrophe) with another string constant (here: 🕶 to use a simple "replace" action?  
Where is the advantage of the "format" action?

---

<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: [January 30, 2015, 7:23am UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/5 "2015-01-30T07:23:17Z")

</div>

> [@rko31415](#):
>
> Thanks for the prompt response but your suggestions do not work with the FORMAT statement.  
> I've tried the following: ......

'a''c' same as \>ac\<

'a''''c' same as \>a'c\<  
''a'c'' syntax error, because of odd number of apostrophes  
'''a'c''' syntax error, because of odd number of apostrophes  
''a''c'' same as: \>'a'c'\<  
'''a''c''' same as: \>'ac'\<  
''a'''c'' syntax error, because of odd number of apostrophes  
'''a'''c''' syntax error, because of odd number of apostrophes  
''a''''c'' same as: \>'a''c'\<  
'''a''''c''' same as: \>'a'c'\<

 

Your examples do not require the function $regexp(), why do you use it?  
Using the action "Tag-Tag" you can test a formatstring, the preview displays the result instantly.

 

DD.20150130.0928.CET

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [February 1, 2015, 1:18pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/6 "2015-02-01T13:18:53Z")

</div>

I use FORMAT TITLE for the following:  
$if($stricmp(%album%,Notebook on Cities and Culture),$regexp(%title%,'^S\d+E\d+: Notebook on Cities and Culture.s Korea Tour:','Korea Tour.'),%title%)

S4E24: Notebook on Cities and Culture's Korea Tour: Eating It All Together with Daniel Gray --\>  
Korea Tour. Eating It All Together

The idea would be to replace the period (.) with a single apostrophe (') in Culture.s

This is just one example of where I use FORMAT TITLE instead of a plain REPLACE or REPLACE WITH expression

Thanks

---

<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 1, 2015, 2:13pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/7 "2015-02-01T14:13:44Z")

</div>

> [@rko31415](#):
>
> I use FORMAT TITLE ...

So you use an action "Format value" to set the tag-field TITLE using this formatstring ...

**TITLE \<== $if(** 

**```
  <!--coloro:#800080--><span style="color:#800080"><!--/coloro-->$stricmp<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->(<!--colorc--></span><!--/colorc--><!--coloro:#0000a0--><span style="color:#0000a0"><!--/coloro-->%ALBUM%<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->Notebook on Cities and Culture<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc-->
  <!--coloro:#800080--><span style="color:#800080"><!--/coloro-->$regexp<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->(<!--colorc--></span><!--/colorc--><!--coloro:#0000a0--><span style="color:#0000a0"><!--/coloro-->%TITLE%<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->^S\d+E\d+: Notebook on Cities and Culture.s Korea Tour:<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->Korea Tour.<!--colorc--></span><!--/colorc--><!--coloro:#008080--><span style="color:#008080"><!--/coloro-->'<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->,<!--colorc--></span><!--/colorc-->
  <!--coloro:#0000a0--><span style="color:#0000a0"><!--/coloro-->%TITLE%<!--colorc--></span><!--/colorc--><!--coloro:#000000--><span style="color:#000000"><!--/coloro-->)<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 

So you apply the function $regexp here to handle prefixes like '^S\d+E\d+' in the tag-field TITLE.  
If the regexp matches the rule, then you replace the existing value with the text 'Korea Tour.', ...  
otherwise the tag-field TITLE is used as is.  
If you are unsure whether the word "Cultures" or "Culture.s" or "Culture's" does exist, ...  
then you can use a placeholder and wildcard symbol, as allowed for a regular expression.

 **$regexp(%TITLE%,'^S\d+E\d+: Notebook on Cities and Culture.+?s Korea Tour:','Korea Tour.'), ... or ... $regexp(%TITLE%,'^S\d+E\d+: Notebook on Cities and Culture.\*s Korea Tour:','Korea Tour.'),** 

Note: In the Regexp language the dot means any character.

 

Because you have already used the one dot character as the placeholder for one unknown character, ...  
then the function $regexp replaces the entire given string on match for all spellings of "Culture.s" ...  
with the text "Korea Tour.".

 

Anyway ... I got the impression, that you do not understand what you are doing there ...  
... or is it me?

 

> [@rko31415](#):
>
> The idea would be to replace the period (.) with a single apostrophe (') in Culture.s

 

So here is a proposal to replace the dot character with an apostrophe, within the word "Culture.s".

 **TAGFIELD \<== $replace(%TAGFIELD%,'Culture.s','Culture''''s') ... or ... TAGFIELD \<== $replace(%TAGFIELD%,'Culture.s','Culture'$char(39)'s') ... or ... replace all dots ... TAGFIELD \<== $replace(%TAGFIELD%,'.',$char(39)) ... or ... TAGFIELD \<== $replace(%TAGFIELD%,'.','')** 

DD.20150201.1658.CET

---

<div class="post-metadata">

### Author: ![rko31415](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/f19dbf/32.png) [@rko31415](https://community.mp3tag.de/u/rko31415)
#### Post date: [February 2, 2015, 3:45pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/8 "2015-02-02T15:45:25Z")

</div>

yes obviously we have a failure to communicate. i go back to my original post ... i want to escape a single apostrophe within a FORMAT statement that uses a literalized expression.

so FORMAT TITLE $if($eql(%album%,'statement containing a single apostrophe'),'results',%title%) is another example.

I use FORMAT containing literalized expressions quite often and in a variety of ways and it would be nice to be able to include statements containing single apostrophes (i.e., it would be nice to escape single apostrophes).

Rgds

---

<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 2, 2015, 4:00pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/9 "2015-02-02T16:00:01Z")

</div>

> [@rko31415](#):
>
> yes obviously we have a failure to communicate. ...  
> $if($eql(%album%,'statement containing a single apostrophe'),'results',%title%) is another example. ...  
> statements containing single apostrophes (i.e., it would be nice to escape single apostrophes). ...

Read Mp3tag manual ...  
if you want to display one apostrophe, then you have to write two apostrophes.

**'statement containing a ==\>''''\<== single apostrophe' |---part1------------------| |----part3------------|** 

**```
                        <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->==<!--colorc--></span><!--/colorc-->
                     <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->apostrophe<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 

... or ...

 **'statement containing a ==\>'$char(39)'\<== single apostrophe' |---part1------------------| |----part3------------|** 

**```
                        <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->=========<!--colorc--></span><!--/colorc-->
                       <!--coloro:#000000--><span style="color:#000000"><!--/coloro-->apostrophe<!--colorc--></span><!--/colorc--></b><!--fontc--></span><!--/fontc--><!--sizec--></span><!--/sizec-->**

**```**

 

Verify the Formatstring in the action [Alt+5] "Tag-Tag", the preview displays the result.

 

DD.20150202.1808.CET

 

> [@rko31415](#):
>
> ... $if($eql(%album%,'statement containing a single apostrophe'),'results',%title%) is another example. ...

 

To be nitpicking ...  
... the text string 'statement containing a single apostrophe'  
... does **not** contain a single apostrophe!

 

DD.20150202.1842.CET

---

<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 2, 2015, 4:28pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/10 "2015-02-02T16:28:24Z")

</div>

> [@rko31415](#):
>
> ... i want to escape a single apostrophe within a FORMAT statement that uses a literalized expression. ...

Here is an action group to simulate the process ...

Begin Action Group **Test2015#20150202.rko31415.Replace.Apostrophe** 

Action #1  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TEST**  
_Formatstring:_ **'statement containing a ==\>''''\<== single apostrophe'**

 

Action #2  
_Actiontype 5:_ **Format value**  
_Field \_\_\_\_\_\_:_ **TEST\_ESCAPED**  
_Formatstring:_ **'escaped: '$replace(%TEST%,'','''')**

 

End Action Group **Test2015#20150202.rko31415.Replace.Apostrophe** (2 Actions)

 

DD.20150202.1830.CET

---

<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:25pm UTC](https://community.mp3tag.de/t/literalized-expression-containing-a-single-apostrophe/16547/11 "2026-02-09T12:25:30Z")

</div>


