768x90 Getting Online Shouldn't be Tough- $7.49 .com Domains at Go Daddy

Random Characters in Ruby on Rails

  • AlphaNumeric Random Characters
>> chars = ("a".."z").to_a + ("1".."15").to_a
>> newpass = Array.new(8, '').collect{chars[rand(chars.size)]}.join
>> "8xa2b13f"

  • Another AlphaNumeric Random Characters
>> (1..8).map{ (0..?z).map(&:chr).grep(/[a-z\d]/i)[rand(62)]}.join
>> "JH789gfd"

  • ASCII Random Characters
>> (0..5).inject('') { |r, i| r << rand(93) + 33 }
>> "S#;og^"


No Response to "Random Characters in Ruby on Rails"

 
powered by Blogger