I want to use regular expressions to check numeric ranges, I have come up
with the following, and it works, but I was wondering whether there is an
easier regex that can be constructed, one you look at and go "yes, I see
that you want to check for a range"...
 
<cfset string = "50" />
<p>Between 25 and 75</p>
<cfoutput>
 
<cfloop from="1" to="80" index="i">
#i# is #yesnoformat( refindnocase( "\b[3-7][0-5]|[3-6][0-9]|2[5-9]\b", i )
)#<br>
</cfloop>
 
</cfoutput>
 
Also, to construct this regex took me a while, the logic I used to construct
it was
 
- first allow 3 to 7 in the ten range and 0 to 5 in the one range, allowing
30,31,32,33,34,35,40,41,42,43,44,45 ..... 75
- then allow 3-6 in the ten range and 0 to 9 in the one range, allowing
30,31,32,33,34,35,36,36,37,38,39,40,41 .... 69
- then allow the litteral 2 and 5-9 in the one range, allowing
25,26,27,28,29
Which covers the whole range I want to check for.
 
Anyone?
-- 
Taco Fleur
Senior Web Systems Engineer
http://www.webassociates.com <http://www.webassociates.com/> 

 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186046
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to