The expression [^a-z0-9] means match any character that is NOT a-z or 0-9. That will 
return only special characters. You probably want
REFindNoCase("^[- a-z0-9]*$", str)
This will return 1 if the following happens. 
at the start of the string (the carat) look for a dash, a space or any character of 
a-z or 0-9. Match as many of these as you can until the end of the string (the dollar 
sign). 
"New York" - N is the first character at the start of the string. There are only 
letters and a space. The k is the last character in the string. The function will 
return 1 (success).
"Wilkes-Barre" - W is the first character of the string. There are only letters and a 
dash. e is the last character in the string. The function will return 1 (success)
"[EMAIL PROTECTED]" - m is the first character in the string. There is an at 
sign in the string. The function will return 0 (failure). 
There's a tutorial on RegEx at www.houseoffusion.com on the front page.


> I want to do a regular expression validation on a form field (city).
> However, I'm rather unfamiliar with regular expressions.
> 
> How would I rewrite the expression so that it will allow a "-" and a
> space.
> For Example:  "Wilkes-Barre" or "Los Angeles" would be accepted. 
> 
> I can't seem to find anything on CFLib which would allow me to accept
> "-" and "spaces"
> 
> This is what I have so far:
> 
> REFindNoCase("[^a-z0-9]", str)
> 
> 
> Thanks,
> Mark
> 
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to