Link to home
Start Free TrialLog in
Avatar of fozzynet
fozzynet

asked on

I need some more regular expression help

I'm having an issue creating a rule that detects if a word contains invalid characters. The word is validated through a form field. I do not want to use javascript. What I have so far is:

<cfelseif NOT REFindNoCase ('[a-z0-9-]',#form.base#)>
<cfoutput>Word contains invalid characters</cfoutput>

This code works great if the word I put in the form field is "@#$%@$#%" but if the word contains a-z or 0-9 AND invalid characters, "word@#$here" it doesn't give the error. The only characters I want to allow are a-z,0-9 and hyphens. Please help. Thank you.
ASKER CERTIFIED SOLUTION
Avatar of weeezl
weeezl

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of weeezl
weeezl

This basically tells it to search from the beginning of the string to the end of the string looking for all matches.

If you want to learn about the functions, there's a good tutorial here:

http://etext.lib.virginia.edu/helpsheets/regex.html
Avatar of fozzynet

ASKER

This worked absolutely great. Thank you so much.