Forum Moderators: coopster
or
regex
^[A-Za-z0-9]+$
preg_match('/^[a-z0-9]+$/iD', $text);
Regards
Michal
>> and punctuations
$pattern = "/[^\w\s]/";
echo [url=http://us2.php.net/manual/en/function.preg-replace.php]preg_replace[/url]($pattern,'',$string);
Good luck :)
Can someone explain this:
$pattern = "/[^\w\s]/";
I know its regular expressions, but its a bit confusing.
"/ - start of the pattern
[^ - negate the following
\w - anything digits?
\s - anything with letters?
] - closing bracket of the regular expression
/" - end of the pattern
Am I correct on the above? I had to spend some good amount of time learning it.
thx
Actually, \w represents any "word" character, which is alphanumeric and the underscore.
>>>\s - anything with letters?
Space characters
Refer to Pattern Syntax [us3.php.net] or Regular Expressions Explained [webmasterworld.com] for more details.
Best of luck!