LoginSignup
0
0

More than 5 years have passed since last update.

ある文字列から漢字のみ削除する

Last updated at Posted at 2017-08-11
str = "a亜1a亜2a亜3a亜4a亜5a亜6a亜7"

str.delete('[一-龠]')

str.gsub(/\p{Han}+/, "")
puts str


=> "a1a2a3a4a5a6a7"
0
0
2

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
0
0