I have tried:
preg_match("/^[a-zA-Z0-9]", $value)
but im doing something wrong i guess.
This question is related to
php
regex
preg-match
You left off the /
(pattern delimiter) and $
(match end string).
preg_match("/^[a-zA-Z0-9]+$/", $value)
As the OP said that he wants letters and numbers ONLY (no underscore!), one more way to have this in php regex is to use posix expressions:
/^[[:alnum:]]+$/
Note: This will not work in Java, JavaScript, Python, Ruby, .NET
So it should fail anyway, but if it may work, it matches against just one digit at the beginning of the string.
/^[a-z0-9]+$/i
try this way .eregi("[^A-Za-z0-9.]", $value)
Source: Stackoverflow.com