Forum Moderators: coopster

Message Too Old, No Replies

preg match and replace escape characters

         

wesg

2:45 am on Sep 12, 2008 (gmt 0)

10+ Year Member



I wrote a wordpress function to replace text, but I'm having trouble getting the result I want.

The text I'm search for is

?phpMyAdmin=CC-tisnANYFAOkLqSlHgaMdmEG1
and I need to know which characters need to be escaped.

My preg_match statement is surrounded by #, and I'm not quite sure what the difference is between that and / so I don't know what changes are allowed.

Any suggestions?

eelixduppy

2:58 am on Sep 12, 2008 (gmt 0)



>> I need to know which characters need to be escaped

Any of the meta-characters in the pattern string need to be escaped (there's a special case for character classes). There's more information at php.net: [php.net...]

coopster

12:49 pm on Sep 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



preg_quote [php.net] may be a function of interest as well.