LoginSignup
35
28

More than 5 years have passed since last update.

全角数字を半角数字に変換するお手軽な方法

Posted at

これだけ

s = "0987654321"
s.tr!("0-9", "0-9")
p s # => 0987654321

NKFとか使わなくても、数字くらいなら、trで変換するのがお手軽。
(カタカナとかになると、全半角で文字数も変わってくるのでtrでは難しい)

35
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
28