[Newbies] Re: '($1,925.46)' asNumber

Ron Teitelbaum ron at usmedrec.com
Fri Jul 1 21:36:20 UTC 2016


 

From: Joseph Alotta
Sent: Friday, July 01, 2016 2:59 PM



Thanks, Ron.  I needed to preserve the negative, so I append a minus sign,
then use your snippet. 



[Ron Teitelbaum] Excellent!  Well done!

,

str := '($1,925.46)' . 
('(*)' match: str ) ifTrue: [str := '-', str]. 
str := str reject:  [:e | '($,)' includes: e]. 
num := str asNumber  => -1925.46 

Sincerely, 

Joe. 




 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20160701/1ac7370c/attachment.htm


More information about the Beginners mailing list