31Aug/090
Useful RegEx: Check if list contains only integers
Trivial, but useful... For 0 and positive integers only:
^[0-9]+(?:\,[0-9]+)*$
If you wish to include negative integers:
^(?:-?[0-9]+)(?:\,(?:-?[0-9]+))*$
So this might be a useful validity checker function:
<cffunction name="lstContainsIntegersOnly" output="no" returntype="boolean" access="private"> <cfargument name="lstI" required="yes" type="string"> <cfargument name="bNegativeAllowed" required="no" type="boolean" default="false"> <cfscript> var bIntegersOnly = FALSE; if (arguments.bNegativeAllowed) { if (ReFind('^(?:-?[0-9]+)(?:\,(?:-?[0-9]+))*$',arguments.lstI)) { bIntegersOnly = TRUE; } } else { if (ReFind('^[0-9]+(?:\,[0-9]+)*$',arguments.lstI)) { bIntegersOnly = TRUE; } } return bIntegersOnly; </cfscript> </cffunction>