æ£è¦è¡¨ç¾ã®ä¸ã§ãå½±ã®èãå
èªã¿ã§ããã使ãããã«ãã£ã¦ã¯é常ã«å¼·åãªéå
·ã«ãªãã¾ãã æ°åãä¸æ¡ãã¨ã«åºåã£ã¦ã³ã³ããæ¿å
¥ãããå ´åãèãã¾ãããã ä¾ãã°"1234567890"ã¨ããæååã"1,234,567,890"ã«ç½®æãããããã§ããã çµè«ããè¨ãã¨ããããè¡ãã«ã¯ä»¥ä¸ã®ããã«ãã¾ãã text = "1234567890" puts text.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, '\1,') ãããã訳ãåãããªãã¨æãã¾ãã®ã§ãé ã追ã£ã¦èª¬æãã¦ããã¾ãããã ã¾ããããã¦ããã¦ã»ãããã¨ã¯ãå
èªã¿ã¯æååãããããã¦ãããã©ããã¯èª¿ã¹ãããã©ããããããã¤ã³ã¿ã¯é²ããªããã¨ãããã¨ã§ãã ããä¸ã®ä¾ã§ãå
èªã¿ãç¨ããã«text.gsub(/(\d)(\d\d\d)+/, '\1,')ã¨ç½®æãããã¨ããã¨ãã¾ãããã ããã¨ãæåã®(\d)ã"
{{#tags}}- {{label}}
{{/tags}}