Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

rails print number with space

number.to_s.reverse.scan(/d{1,3}/).join(",").reverse

number            #=> 12345678
.to_s             #=> "12345678"
.reverse          #=> "87654321"
.scan(/d{1,3}/)  #=> ["876","543","21"]
.join(",")        #=> "876,543,21"
.reverse          #=> "12,345,678"
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails c add timings 
Ruby :: add key and value to the beginning of a hash ruby 
Ruby :: ruby string interpolation lazy evaluation 
Ruby :: ruby timeout 
Ruby :: ruby decode base64 
Ruby :: how to use custom switch in rails 
Ruby :: rails run rake task 
Ruby :: rails class sti reminders 
R :: r delete all variables 
R :: how to add random numbers randomly in a dataframe in r 
R :: R p value star 
R :: select all columns except one by name in r 
R :: multiple intersect r 
R :: r dataframe column factor 
R :: rename columns in table r 
R :: How to Convert a Factor in R 
R :: r remove row dataframe 
R :: how to convert negative values to positive in R 
R :: r - remove NA from a coulm 
R :: geom_point r 
R :: knn in r 
R :: r get date from year and day 
R :: if in r 
R :: logical vector passed in R 
R :: count certain number of alphabets in a string r 
R :: change to posixct in r 
R :: SSL certificate problem in R 
R :: r for data science 
Rust :: rust create bigint from string 
Rust :: rust u32 to f64 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =