Page 1 of 1

Simple regex

Posted: Sat Oct 15, 2005 5:05 pm
by alex.barylski

Code: Select all

$temp = preg_replace('/[^a-z]/ig', '', $temp);
Would this strip any characters except A to Z???

Thus:

Code: Select all

$temp = 'The quick/Brown fox/Jumped over - the lazy dog';
would yield:

Code: Select all

$temp = 'ThequickBrownfoxJumpedoverthelazydog';
If it doesn't, how can I accomplish this using regex???

Also...

when I use the above REGEX...I don't suppose this is portable to other languages other than English???

What I mean is...in french...some characters have that little apostrphe, but are still considered valid characters in the range of A-Z aren't they???

Cheers :)

Posted: Sat Oct 15, 2005 5:55 pm
by feyd
there is no g modifier for pcre, it's global always in the case of preg_replace() ;)

it will not capture accented characters.

Posted: Sat Oct 15, 2005 7:42 pm
by alex.barylski
feyd wrote:there is no g modifier for pcre, it's global always in the case of preg_replace() ;)

it will not capture accented characters.
Wicked...thanks :)