
Copy link to clipboard
Copied
Is there a ColdFusion function that will check that a string has only alpha characters (not numeric or for example &,$, etc)? I'm trying to avoid creating a string of all alpha characters or all non-alpha characters to loop over and check against.
1 Correct answer
That could easily be accomplished with a regular expression search using the REFIND() function.
Something like this off the top of my head and untested example. REFIND("[^A-Za-z]",yourStringVar). If that returns true then there are characters other then alpha characters in the string.
Copy link to clipboard
Copied
That could easily be accomplished with a regular expression search using the REFIND() function.
Something like this off the top of my head and untested example. REFIND("[^A-Za-z]",yourStringVar). If that returns true then there are characters other then alpha characters in the string.

Copy link to clipboard
Copied
That does the trick. I was looking through the docs but could only manage to get to - REFind("[A-Za-z]",form.txt_firstname). Wasn't working but yours does, thanks.
Copy link to clipboard
Copied
The difference is the carrot ^ character. It is the regex not operator. Your search [A-Za-z] was finding all the alpha characters, but that is what you want in your string. Adding the ^ to get [^A-Za-z] is finding any character that is NOT an alpha character.

