Need some help with this Regex...
Hi, all... Why doesn't this Regex validate the field entry 24 as a valid number? : CFIF Len(Trim(Form.Years)) and Not IsNumeric(REReplace(Len(Trim(Form.Years)), [0-9],,All)) I thought this would mean: If Form.Years has some content and if, after taking away all digits 0 thru 9, what's left is not a valid number, then... Rick ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272746 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Need some help with this Regex...
For starters, you probably want to remove the Len() inside of: REReplace(Len(Trim(Form.Years)), [0-9],,All) To: REReplace(Trim(Form.Years), [0-9],,All) Plus, the NOT IsNumeric() will ALWAYS be true since you are stripping out all numbers. IsNumeric() will never be true... Somewhere, your logic is screwey... What are you trying to do (in english)? .. Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com Need ColdFusion Help? www.bennadel.com/ask-ben/ -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Thursday, March 15, 2007 3:12 PM To: CF-Talk Subject: Need some help with this Regex... Hi, all... Why doesn't this Regex validate the field entry 24 as a valid number? : CFIF Len(Trim(Form.Years)) and Not IsNumeric(REReplace(Len(Trim(Form.Years)), [0-9],,All)) I thought this would mean: If Form.Years has some content and if, after taking away all digits 0 thru 9, what's left is not a valid number, then... Rick ~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272747 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Need some help with this Regex...
On 3/15/07, Rick Faircloth [EMAIL PROTECTED] wrote: CFIF Len(Trim(Form.Years)) and Not IsNumeric(REReplace(Len(Trim(Form.Years)), [0-9],,All)) Let me talk this out... Take form.years Trim it get the length of it replace all numbers with blanks check to see if the result is numeric #1 - I would trim form.years only once.. not every time you use it. If you're using CFMX 7, just is isValid(): cfset form.years = trim(form.years) cfif len(form.years) and not isValid(integer,form.years) rick -- Join the Open Source Coldfusion NCAA Pool for a chance to win a 2 gig USB flash drive! http://www.opensourcecf.com/forums/ncaapool.cfm ~| Macromedia ColdFusion MX7 Upgrade to MX7 experience time-saving features, more productivity. http://www.adobe.com/products/coldfusion?sdid=RVJW Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272749 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Need some help with this Regex...
I would trim form.years only once... This is a jQuery Ajax validation, and the form field validates onblur every time after the field is focused. cfset form.years... I don't want to actually change for the form data... I want to return it to them as they entered it. If you're using CFMX 7... Ha! You don't realize you're talking to a luddite here... Still on CF 4.5! Rick -Original Message- From: Rick Root [mailto:[EMAIL PROTECTED] Sent: Thursday, March 15, 2007 3:46 PM To: CF-Talk Subject: Re: Need some help with this Regex... On 3/15/07, Rick Faircloth [EMAIL PROTECTED] wrote: CFIF Len(Trim(Form.Years)) and Not IsNumeric(REReplace(Len(Trim(Form.Years)), [0-9],,All)) Let me talk this out... Take form.years Trim it get the length of it replace all numbers with blanks check to see if the result is numeric #1 - I would trim form.years only once.. not every time you use it. If you're using CFMX 7, just is isValid(): cfset form.years = trim(form.years) cfif len(form.years) and not isValid(integer,form.years) rick -- Join the Open Source Coldfusion NCAA Pool for a chance to win a 2 gig USB flash drive! http://www.opensourcecf.com/forums/ncaapool.cfm ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272756 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Need some help with this Regex...
Hi, Ben... and thanks for the reply... Ok... I figured out the problem... my Regex is correct as is, however, a conditional statement prior to it needed to be adjusted. Here's what's going on: jQuery is submitting info via Ajax from a form field to the code below for validation. (In this case I'll use the Years form data) CFIF Not Len(Trim(Form.Years)) CFSET Years_Error_Message = Please enter the number of years. /CFIF CFIF Len(Trim(REReplace(Form.Years, [0-9],,All))) and Not IsNumeric(REReplace(Trim(Form.Years), [0-9],,All)) CFSET Years_Error_Message = Please enter a valid number for years. /CFIF Now, I've change the first condition of the second CFIF to read: CFIF Len(Trim(REReplace(Form.Years, [0-9],,All)))... That verifies that there is data besides digits, which is what I'm trying to find out. The next condition, after the and, checks to make sure that the data is not numeric after all digits are removed... (this may be redundant now...) Here's the final code (at this point...) for validating the Years field. CFIF Not Len(Trim(Form.Years)) CFSET Years_Error_Message = Please enter the number of years. /CFIF CFIF Len(Trim(REReplace(Form.Years, [0-9],,All))) and Not IsNumeric(REReplace(Trim(Form.Years), [0-9],,All)) CFSET Years_Error_Message = Please enter a valid number for years. /CFIF Rick -Original Message- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Thursday, March 15, 2007 3:34 PM To: CF-Talk Subject: RE: Need some help with this Regex... For starters, you probably want to remove the Len() inside of: REReplace(Len(Trim(Form.Years)), [0-9],,All) To: REReplace(Trim(Form.Years), [0-9],,All) Plus, the NOT IsNumeric() will ALWAYS be true since you are stripping out all numbers. IsNumeric() will never be true... Somewhere, your logic is screwey... What are you trying to do (in english)? ... Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com ~| Create robust enterprise, web RIAs. Upgrade integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272758 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Need some help with this Regex...
Also... you can see how this is working at: http://bodaford.whitestonemedia.com/html/trial_field_validation.cfm Rick -Original Message- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Thursday, March 15, 2007 4:40 PM To: CF-Talk Subject: RE: Need some help with this Regex... Hi, Ben... and thanks for the reply... Ok... I figured out the problem... my Regex is correct as is, however, a conditional statement prior to it needed to be adjusted. Here's what's going on: jQuery is submitting info via Ajax from a form field to the code below for validation. (In this case I'll use the Years form data) CFIF Not Len(Trim(Form.Years)) CFSET Years_Error_Message = Please enter the number of years. /CFIF CFIF Len(Trim(REReplace(Form.Years, [0-9],,All))) and Not IsNumeric(REReplace(Trim(Form.Years), [0-9],,All)) CFSET Years_Error_Message = Please enter a valid number for years. /CFIF Now, I've change the first condition of the second CFIF to read: CFIF Len(Trim(REReplace(Form.Years, [0-9],,All)))... That verifies that there is data besides digits, which is what I'm trying to find out. The next condition, after the and, checks to make sure that the data is not numeric after all digits are removed... (this may be redundant now...) Here's the final code (at this point...) for validating the Years field. CFIF Not Len(Trim(Form.Years)) CFSET Years_Error_Message = Please enter the number of years. /CFIF CFIF Len(Trim(REReplace(Form.Years, [0-9],,All))) and Not IsNumeric(REReplace(Trim(Form.Years), [0-9],,All)) CFSET Years_Error_Message = Please enter a valid number for years. /CFIF Rick ..4 ~| Upgrade to Adobe ColdFusion MX7 The most significant release in over 10 years. Upgrade see new features. http://www.adobe.com/products/coldfusion?sdid=RVJR Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272760 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Help with this regex
Hello I have the following regex: s = rereplace(s, a[^]*href="" ])*[^]*[^]*/a,\1,all); Which should (in theory) replace a href="" here/a With page.htm But instead it just returns click here. Can anyone see where I'm going wrong? Ryan [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Help with this regex
s = rereplace(s, a[^]+href="" ]*)[^]*[^]*/a,\1,all); -Oorspronkelijk bericht- Van: Ryan Mitchell [mailto:[EMAIL PROTECTED] Verzonden: wo 5/11/2003 12:44 Aan: CF-Talk CC: Onderwerp: Help with this regex Hello I have the following regex: s = rereplace(s, a[^]*href="" ])*[^]*[^]*/a,\1,all); Which should (in theory) replace a href="" here/a With page.htm But instead it just returns click here. Can anyone see where I'm going wrong? Ryan _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Help with this regex
Looks like Pascal already posted a fix, but (since you asked) it looks like your problem is that you've got (^[ ]) instead of ([^ ]). Happy Regexing. --Ben Doom Ryan Mitchell wrote: Hello I have the following regex: s = rereplace(s, a[^]*href="" ])*[^]*[^]*/a,\1,all); Which should (in theory) replace a href="" here/a With page.htm But instead it just returns click here. Can anyone see where I'm going wrong? Ryan [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Help with this regex
After Ben's post I noticed a space I didn't see before. It should be s = rereplace(s, a[^]+href=""> with no spaces at all in the regexp. Pascal -Oorspronkelijk bericht- Van: Pascal Peters Verzonden: wo 5/11/2003 14:34 Aan: CF-Talk CC: Onderwerp: RE: Help with this regex s = rereplace(s, a[^]+href="" ]*)[^]*[^]*/a,\1,all); [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Help with this regex
Wonderful thanks :) On 5/11/03 4:06 pm, Pascal Peters [EMAIL PROTECTED] wrote: After Ben's post I noticed a space I didn't see before. It should be s = rereplace(s, a[^]+href=""> with no spaces at all in the regexp. Pascal -Oorspronkelijk bericht- Van: Pascal Peters Verzonden: wo 5/11/2003 14:34 Aan: CF-Talk CC: Onderwerp: RE: Help with this regex s = rereplace(s, a[^]+href="" ]*)[^]*[^]*/a,\1,all); [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]