There is no need for cfif - here is a nice concise way to do this:
<cfset isValidString = NOT refind( '[^\w.]' , Arguments.StringToCheck )/>
Alternatively, you can do it like this:
<cfset isValidString = refind( '^[\w.]*$' , Arguments.StringToCheck ) />
(To prevent an empty line, change * to + )
This method can simplify the application of other restrictions (for example, it must start with a letter, etc.), and in any case it is a slightly more straightforward way to express the original check.
Please note that ^ here is an anchor meaning "start of line / line" (with $ - corresponding end), more information here .
source share