I need a command to replace (erase) the characters · and | from a string.

Consider the following naive code:




  \convertchar[q]{#1}        {·}{}%


It gives a stack exceeded error; I think the reason is that the occurrences of · are passed as \IeC {\textperiodcentered } to \convertchar.

Also, the substitution of | is not working. I think that's due to the font encoding as suggested by the manual of stringstrings.

Fiddling with \unexpanded and \detokenize got me nowhere: I don't quite get what is happening, so I just made a mess.

What is the best way to write such a command? Why?

(An implementation using xstring is equally welcome; I tried, obtaining essentially the same results.)


The problem is, as far as I can see, that stringstrings tries expansion and that · is a two byte character.

I'd suggest expl3 and \tl_remove_all:Nn that doesn't attempt expansion.




  \tl_set:Nn \l_tmpa_tl { #1 }
  \tl_remove_all:Nn \l_tmpa_tl { · }
  \tl_remove_all:Nn \l_tmpa_tl { | }
  \tl_use:N \l_tmpa_tl


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.