I have found this Flex3 Tool useful a few times 
http://ryanswanson.com/regexp/#start

Using it I got this to work:
/^[0-3]?[0-9](.[0-9])?$/

Haven’t had a chance to plug it into a test CF page though.


On Sep 20, 2:29 pm, Aaron Rouse <[email protected]> wrote:
> You could use the IsValid on a range then do a check for no more than the
> tenths place.  The IsValid will see if it is numeric or not and range from 0
> to 40.  Then use regex for the decimal place.  It might lesson the regex and
> make it easier at a later date to remember what was done if/when a
> modification to it is needed.  That assumes regex is not someones strong
> point.
>
> With that said if someone just really was opposed to using regex then
> another way would be to get messy with list functions(which sadly I read way
> too well):
>
> <cfset blah = 40 />
> <cfif IsValid("range", blah, 0, 40) AND (ListLen(blah, ".") IS 1 OR
> ListLast(blah, ".") LT 10)>TRUE<cfelse>FALSE</cfif>
>
> On Mon, Sep 20, 2010 at 1:05 PM, Chris Champion
> <[email protected]>wrote:
>
>
>
> > Whoops, dropped an "or" in my copy/pasting.
> > <cfif NOT isNumeric(testNum) OR testNum LT 0 OR testNum GT 40 OR
> > refind("^[0-9]{1,2}(\.[0-9])?$",testnum) is 0>
> >  <cfoutput>You done failed the validation, pardner.</cfoutput>
> > </cfif>
>
> >   On Mon, Sep 20, 2010 at 1:04 PM, Chris Champion <
> > [email protected]> wrote:
>
> >> Ah then that's easier. Use ^[0-9]{1,2}(\.[0-9])?$ for your regex. (In
> >> human, that means "at the beginning of the string, find one or two numbers
> >> between 0 and 9, optionally followed by a period and another number, then
> >> the end of the string.")
>
> >> <cfif NOT isNumeric(testNum) testNum LT 0 or testNum GT 40 or
> >> refind("^[0-9]{1,2}(\.[0-9])?$",testnum) is 0>
> >> <cfoutput>You done failed the validation, pardner.</cfoutput>
> >> </cfif>
>
> >> On Mon, Sep 20, 2010 at 12:20 PM, Mark Davis <[email protected]> wrote:
>
> >>> this will be in a CF function used for server-side form validation.
>
> >>> On Mon, Sep 20, 2010 at 12:08 PM, Chris Champion <
> >>> [email protected]> wrote:
>
> >>>> Ick, numeric ranges are actually pretty difficult to do in regex. If
> >>>> possible I would do two distinct functions and "wrap" a regex for the
> >>>> numeric pattern ##.# with a separate range check for 0-40. Where will 
> >>>> you be
> >>>> implementing this? In CF functions, in a validation in a cfinput, or some
> >>>> freestanding javascript?
>
> >>>> On Mon, Sep 20, 2010 at 11:03 AM, <[email protected]> wrote:
>
> >>>>>  Here, let me Google That For You...
>
> >>>>>http://www.txt2re.com/
>
> >>>>> *James E. Thomas*
> >>>>> Baker Botts L.L.P. Web Developer
> >>>>> office: 713.229.2196 | mobile: 832.373.8117
>
> >>>>>  ------------------------------
> >>>>> *From:* [email protected] [mailto:[email protected]] *On
> >>>>> Behalf Of *Mark Davis
> >>>>> *Sent:* Monday, September 20, 2010 10:44 AM
> >>>>> *To:* [email protected]
> >>>>> *Subject:* [houcfug] regex help
>
> >>>>>   Where are the regex experts?  I fully admit I suck at regex so I am
> >>>>> asking for help.  Can anyone help me construct a regex that will accept
> >>>>> numbers 0 through 40 (inclusive) and allow for a decimal point and one
> >>>>> decimal place?  So 0, .5, 6.8 and 40 are valid.   3.77, 40.1 are not 
> >>>>> valid.
>
> >>>>> Who wants to be my hero?
>
> >>>>> Thanks
>
> >>>>> Mark
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the "Houston
> >>>>> ColdFusion Users' Group" discussion list.
> >>>>> To unsubscribe, send email to [email protected]
> >>>>> For more options, visithttp://groups.google.com/group/houcfug?hl=en
>
> >>>>> *Confidentiality Notice:* The information contained in this email and
> >>>>> any attachments is intended only for the recipient[s] listed above and 
> >>>>> may
> >>>>> be privileged and confidential. Any dissemination, copying, or use of or
> >>>>> reliance upon such information by or to anyone other than the 
> >>>>> recipient[s]
> >>>>> listed above is prohibited. If you have received this message in error,
> >>>>> please notify the sender immediately at the email address above and 
> >>>>> destroy
> >>>>> any and all copies of this message.
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the "Houston
> >>>>> ColdFusion Users' Group" discussion list.
> >>>>> To unsubscribe, send email to [email protected]
> >>>>> For more options, visithttp://groups.google.com/group/houcfug?hl=en
>
> >>>> --
> >>>> You received this message because you are subscribed to the "Houston
> >>>> ColdFusion Users' Group" discussion list.
> >>>> To unsubscribe, send email to [email protected]
> >>>> For more options, visithttp://groups.google.com/group/houcfug?hl=en
>
> >>> --
> >>> You received this message because you are subscribed to the "Houston
> >>> ColdFusion Users' Group" discussion list.
> >>> To unsubscribe, send email to [email protected]
> >>> For more options, visithttp://groups.google.com/group/houcfug?hl=en
>
> >   --
> > You received this message because you are subscribed to the "Houston
> > ColdFusion Users' Group" discussion list.
> > To unsubscribe, send email to [email protected]
> > For more options, visithttp://groups.google.com/group/houcfug?hl=en
>
> --
> Aaron Rousehttp://www.happyhacker.com/

-- 
You received this message because you are subscribed to the "Houston ColdFusion 
Users' Group" discussion list.
To unsubscribe, send email to [email protected]
For more options, visit http://groups.google.com/group/houcfug?hl=en

Reply via email to