LoginSignup
3
1

More than 5 years have passed since last update.

rubyでランダム英数字を生成(l1,o0,9q等似た文字を除外)

Last updated at Posted at 2017-03-28

lと1、oと0など似た文字を除外してランダム文字を生成させるコード

length=8
except="19q0iol" #似た文字は使用しない
loop do
  v = rand(36**(length * 3)).to_s(36).delete(except)[0,length]
   if v.size == length
    p v
    break
   end
end
3
1
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
3
1