<cfset variables.ThisRegex="^[A-Z]+$">
If you want to only accept uppercase or empty string:
<cfset variables.ThisRegex="^[A-Z]*$">
If you want to accept all characters except lowercase:
<cfset variables.ThisRegex="^[^a-z]+$">
The thing is: you were matching a single character. In validation
regexps you generally have to match the entire string. That is why I use
^ (matches beginning of string) and $ (matches end of string).
And you don't need "#variables.ThisRegex#", just do variables.ThisRegex
(the quotes and hashes cancel each other).
> -----Original Message-----
> From: Matt Robertson [mailto:[EMAIL PROTECTED]
> Sent: maandag 31 mei 2004 4:18
> To: CF-Talk
> Subject: Rookie Regex question
>
> I want to be able to plug in a dynamic regex, like you see
> below. Its part of a thing that lets someone specify
> regex-based form field validation.
>
> Thing is, the code below passes and I want it to fail. I'm
> sure the problem is my rudimentary regex skills. I'm doing
> something stoopid here, but I can't find it.
>
> If I wanted the string below to accept only uppercase chars,
> A to Z, what would I change here?
>
> <cfset variables.ThisRegex="[A-Z]">
> <cfset form.FieldValue="HOLTSVILLEblah"> <cfif
> REFind("#variables.ThisRegex#",form.FieldValue)>
> passed<cfelse>failed</cfif>
> <cfset test=REFind("#variables.ThisRegex#",form.FieldValue)>
> <cfdump var="#variables#">
>
> --------------------------------------------
> Matt Robertson [EMAIL PROTECTED]
> MSB Designs, Inc. http://mysecretbase.com
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

