[texhax] Low-level TeX question: string substitution macro

Michael Doob mdoob at ccu.umanitoba.ca
Tue May 29 16:34:09 CEST 2007

On Tuesday 29 May 2007 8:38 am, Toby Cubitt wrote:
> I'm trying to write an internal macro that does string substitution, in
> order to escape certain characters in the string before writing it to a
> file. (The package is supposed to be writing a sed script, so I need to
> escape characters that have a special meaning in regular expressions.)

Can't sed do this itself? I'm almost afraid to mention this, but
perl has a builtin function called quotemeta which does exactly what you
want. Please, please, please, no language wars. It's just a possible
option for Tony.

Michael Doob                    Telephone: (204) 474-9796
Department of Mathematics       Fax: (204) 474-7606
University of Manitoba          email: Michael_Doob at umanitoba.ca
Winnipeg, MB, Canada R3T 2N2

More information about the texhax mailing list