For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2007 > Re: Need a regex to escape all escapable characters in a string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Need a regex to escape all escapable characters in a string
Larry W. Virden

2007-06-26, 8:09 am

On Jun 25, 4:37 pm, Mel <MelHer...@gmail.com> wrote:
> I need to escape all "escapable" characters in a string.
>
> items like:
> ' " [ ] } { ;
>
> can it be done with a single regex or should it be done individually ?



Well, the quickest way to escape characters is to do something like
set a {characters to escape}

There are, however a couple of exceptions to that - if the string
contains a }, or, I think, if the last character in the string is a
\ .

If you don't feed your string to eval, you may not even need to escape
it.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com