Yes, . means any single character in RegEx - except within a character
class.  Inside character classes the metacharacters lose their meaning
(aside from a leading ^ for negation, backslash for escaping, and the
] to end the class).  So you don't need to escape the . in that
context.  Consider this code:

<cfset s = "123.456\?" />
<cfoutput>
#s#<br />
#REReplace(s, "[^0-9.]", "", "all")#<br />
#REReplace(s, "[^0-9\.]", "", "all")#<br />
#REReplace(s, "[^0-9\\.]", "", "all")#<br />
#REReplace(s, "[^0-9\\]", "", "all")#<br />
</cfoutput>

It will output this:

123.456\?
123.456
123.456
123.456\
123456\

The backslash to escape the period in the third line (your proposal)
is a no-op, because the period doesn't have special meaning to escape
from.

cheers,
barneyb

On Thu, May 13, 2010 at 10:41 AM, DURETTE, STEVEN J (ATTASIAIT)
<sd1...@att.com> wrote:
>
> Barney,
>
> Thanks for correcting my mistake.  One question though, shouldn't it be 
> REReplace(my_number, "[^0-9\.]", "", "all")?
>
> I thought that . meant any single character in RegEx.
>
> Thanks,
> Steve
>
>
> -----Original Message-----
> From: Barney Boisvert [mailto:bboisv...@gmail.com]
> Sent: Thursday, May 13, 2010 1:38 PM
> To: cf-talk
> Subject: Re: Convert to number
>
>
> That won't work, you'll get "100.00", not "100000.00".  Try
> REReplace(my_number, "[^0-9.]", "", "all").
>
> cheers,
> barneyb
>
> On Thu, May 13, 2010 at 10:34 AM, DURETTE, STEVEN J (ATTASIAIT)
> <sd1...@att.com> wrote:
>>
>> Robert,
>>
>> You shouldn't have to strip it in a perfect world, but the comma makes it a 
>> string not a number according to ColdFusion.
>>
>> Try this instead: $#numberFormat(val(my_number), "______.00")#
>>
>> Might not work, I didn't test it.
>>
>> Steve
>>
>>
>> -----Original Message-----
>> From: Robert Harrison [mailto:rob...@austin-williams.com]
>> Sent: Thursday, May 13, 2010 1:28 PM
>> To: cf-talk
>> Subject: Convert to number
>>
>>
>> This is just plain stupid.
>>
>>        Client enters:  100,000.00
>>
>> Formatting is:  $#NumberFormat(my_number,"_______.00")#
>>
>> Cold Fusion Says: Cannot convert  100,000.00 to number.
>>
>> I have to be brain dead. There is no way I should have to strip commas, so
>> what stupid thing am I doing?  Just no seeing it right now.
>>
>> Thanks
>>
>>
>> Robert B. Harrison
>> Director of Interactive Services
>> Austin & Williams
>> 125 Kennedy Drive, Suite 100
>> Hauppauge NY 11788
>> P : 631.231.6600 Ext. 119
>> F : 631.434.7022
>> http://www.austin-williams.com
>>
>> Great advertising can't be either/or.  It must be &.
>>
>> Plug in to our blog: A&W Unplugged
>> http://www.austin-williams.com/unplugged
>>
>>
>>
>> __________ Information from ESET Smart Security, version of virus signature
>> database 5113 (20100513) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.eset.com
>>
>>
>>
>>
>>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:333661
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to