|
Posted by Puzzled on 04/02/07 17:19
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\**
into
%some string*%
for use in a mysql query. Unless I'm misunderstanding something about
the syntax, this
'/(^|[^\\])\*/is'
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,
'/(^|[^\\\])\*/is'
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.
Navigation:
[Reply to this message]
|