Page 1 of 1

preg_replace and percentage sign

Posted: Tue Mar 09, 2010 3:21 am
by Pistons
I'm using PHP preg_replace to replace all characters except alphabetic and numeric values.
The regex looks like this: /[^a-zA-Z0-9]/u

Now I want to exclude the percentage sign from being replaced also.
So normally the regex would look like this /[^%a-zA-Z0-9]/u , which seems to work with the Dreamweaver regex search tool.
When used with preg_replace, the regex breaks.

I've been searching for hours on how to resolve this, but cannot find a single clue.

Re: preg_replace and percentage sign

Posted: Tue Mar 09, 2010 12:48 pm
by ridgerunner
Please post the code you are using that breaks. Also provide some "before" and "after" text that the preg_replace is supposed to accomplish.