for apeiros:
class Numeric
def commify(dec='.', sep=',')
num = to_s.sub(/\./, dec)
dec = Regexp.escape dec
num.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*#{dec})/, "\\1#{sep}").reverse
end
end
for apeiros:
class Numeric
def commify(dec='.', sep=',')
num = to_s.sub(/\./, dec)
dec = Regexp.escape dec
num.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*#{dec})/, "\\1#{sep}").reverse
end
end
This page contains a single entry by zenspider published on April 11, 2007 3:54 PM.
Functional Test Matrix, a visualization was the previous entry in this blog.
zentest version 3.5.0 has been released! is the next entry in this blog.
Find recent content on the main index or look in the archives to find all content.
16000324.commify('.') # =>
~> -:4:in `escape': wrong number of arguments (0 for 1) (ArgumentError) ~> from -:4:in `commify' ~> from -:9Is there a lib I need to get Regexp.escape?
doh. should be fixed.
Merci.
Excellent; thanks for sharing.