Matching a backslash-escaped character

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm having an impossible time figuring out how to match an escaped
char.  It shouldn't be this difficult, so obviously I'm doing
something dumb or not doing what I think I'm doing.

I want to transform, for example

   *some string\**  


   %some string*%

for use in a mysql query.  Unless I'm misunderstanding something about
the syntax, this

should do the job.  But it doesn't.  What I get is a complaint that
there's no closing square bracket, which doesn't make sense unless
it's parsing the string in a funny way.  

If I add a third backslash,  


the complaint goes away, but the transform I get is

    %some string\%  

which doesn't make sense to me at all.  

So I'd greatly appreciate being told what the heck I'm doing wrong.

Re: Matching a backslash-escaped character

I wrote:

Quoted text here. Click to load it

I solved it.  It's amazing how simply giving up and posting a question
can sometimes unlock one's tired mind enough to produce the solution.
Now if only there were a way to do the unlocking without the posting.

Re: Matching a backslash-escaped character

On 2007-04-02 21-13-04, Puzzled wrote:

Quoted text here. Click to load it

In case it didn't work out (it's amazing, how easily we think something
works, while in fact it doesn't, when we are tired :P)... Matching a
""-delimited string that may contain escape sequences (including \") is:


And btw.: Next time you find the answer yourself *after* posting the
question: Please share it, as the newsgroups are also indexed by searching
index and therefor threads might be found by others just looking for what
you were doing.


Site Timeline