Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #4207
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Generate random string matching specific pattern and length |
| Date | Tue, 10 May 2011 16:20:00 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 30 |
| Message-ID | <ff11e0b873337727b724da400a5e5354@ruby-forum.com> (permalink) |
| References | <BANLkTimBHzkQmhhBAb7EEX7WjXc+xzfURQ@mail.gmail.com> <BANLkTinoFJhRF8zq_AAaPkUx5OHKyakcGA@mail.gmail.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1305062466 90977 65.111.164.187 (10 May 2011 21:21:06 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Tue, 10 May 2011 21:21:06 +0000 (UTC) |
| In-Reply-To | <BANLkTinoFJhRF8zq_AAaPkUx5OHKyakcGA@mail.gmail.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 382918 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <ff11e0b873337727b724da400a5e5354@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:4207 |
Show key headers only | View raw
Adam Prescott wrote in post #997841:
> On Tue, May 10, 2011 at 9:56 PM, Kevin <darkintent@gmail.com> wrote:
>
>> 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
>
>
> How's this?
>
> characters = ("A".."Z").to_a + ("a".."z").to_a # there is a shortcut to
> this
> in 1.9, but it escapes me.
> characters << "-"
>
> 10.times.map { a << b.sample }
>
> Sure there's a quicker way.
>
> By the way, /[A-Z|[a-z]|-/ is equivalent to /[A-Za-z-]/.
Of course with all your misnamed/non-existent variables, that code won't
run. Atrocious.
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Generate random string matching specific pattern and length Kevin <darkintent@gmail.com> - 2011-05-10 15:56 -0500
Re: Generate random string matching specific pattern and length Adam Prescott <adam@aprescott.com> - 2011-05-10 16:12 -0500
Re: Generate random string matching specific pattern and length 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-10 16:20 -0500
Re: Generate random string matching specific pattern and length Adam Prescott <adam@aprescott.com> - 2011-05-10 16:24 -0500
Re: Generate random string matching specific pattern and length Adam Prescott <adam@aprescott.com> - 2011-05-10 20:41 -0500
Re: Generate random string matching specific pattern and length Robert Klemme <shortcutter@googlemail.com> - 2011-05-11 02:11 -0500
Re: Generate random string matching specific pattern and length Chris Hulan <chris.hulan@gmail.com> - 2011-05-11 07:50 -0700
Re: Generate random string matching specific pattern and length Kevin <darkintent@gmail.com> - 2011-05-16 21:47 -0500
csiph-web