Ereg version :
if (ereg('^[a-zA-Z0-9.<>()~ _-]+$', $subject)) {
# Successful match
}
Preg version : (after popular demand)
if (preg_match('/^[a-zA-Z0-9.<>()~ _-]+$/', $subject)) {
# Successful match
}
Something like this?
# ^[a-zA-Z0-9.<>()~ _-]+$
#
# Assert position at the beginning of the string «^»
# Match a single character present in the list below «[a-zA-Z0-9.<>()~ _-]+»
# Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
# A character in the range between “a” and “z” «a-z»
# A character in the range between “A” and “Z” «A-Z»
# A character in the range between “0” and “9” «0-9»
# One of the characters “.<>()~ ” «.<>()~ »
# The character “_” «_»
# The character “-” «-»
# Assert position at the end of the string (or before the line break at the end of the string, if any) «$»