View Single Post
Old 03-13-2005, 09:19 AM   #1 (permalink)
DogTags
Registered User
 
Join Date: Mar 2005
Posts: 8
DogTags is on a distinguished road
regex for allowed characters in a form field

Hi All

I'm trying to come up with a regex for validating allowed characters in a form field.

The idea is that if any characters other than those in the approved list are entered in the field, then the form will return an error and message.

I don't know regex from a hole in the ground. So, I'm hoping that someone might have some good ideas about this.

Here is the list of approved characters:

$ALLOWED_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz&#!(-)'+/=?:@\""

Yes, the double quote is also allowed and it is escaped near the end.

What would be a good regex to test for these allowed chars?

Many thanks
DogTags is offline   Reply With Quote