I'm looking to split a numeric random string like "12345567" into the array ["12","345","567"] as simply as possible. basically changing a number into a human readable number array with splits at thousands,million, billions, etc..
my previous solution cuts it from the front rather than back
"'12345567".to_s.scan(/.{1,#{3}}/)
#> ["123","455","67"]
Aucun commentaire:
Enregistrer un commentaire