subrata_ushasi
Junior Poster in Training
52 posts since Aug 2008
Reputation Points: 10
Solved Threads: 5
So only a-z, 0-9, - and _
if (preg_match('/[\w-]*/', $subject)) {
# Successful match
}
else {
# Match attempt failed
}
Update: As minitauros states, use a + instead of a * if you want to match at least a single character.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875