You are here: Matching a backslash-escaped character « PHP Programming Language « IT news, forums, messages
Matching a backslash-escaped character

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация