From: Kevin Date: 2011-05-11T05:56:02+09:00 Subject: Generate random string matching specific pattern and length --e0cb4e43cd31bdb38d04a2f22e2d Content-Type: text/plain; charset=UTF-8 I'm trying to generate a random set of strings to fill a database with that match the following pattern: /^([A-Z]|[a-z]|-)+$/ The array I'm trying to create must contain strings that look like "A12-34-4567" and be exactly ten characters long I have seen code on the internet for generating random strings but I don't have internet at home at the moment to really study examples like the one here: http://coderrr.wordpress.com/2008/10/28/ruby-golf-generating-random-strings I'm guessing that something like map { if /^([A-Z]|[a-z]|-)+$/ & char.len==10 strings<< current_matching_value } would achieve the right solution. Any pointers would be greatly appreciated. --e0cb4e43cd31bdb38d04a2f22e2d--