Forum: Ruby on Rails Reg: regular expression

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C0fa318a0b78f872fd5f3151ee31132f?d=identicon&s=25 Shiva Shiva (shiva_98)
on 2007-03-20 05:57
how to validate using regular expression using


1.name should be alpha numeric
2.min 5 characters and max 15
3."two alphabets followed by a number" format not allowed in the
beginning .if any one have solution.pls send me
B4084fdc8c0512d3402387a87b008035?d=identicon&s=25 Preston Lee (Guest)
on 2007-03-20 06:19
(Received via mailing list)
>
> 1.name should be alpha numeric
> 2.min 5 characters and max 15
> 3."two alphabets followed by a number" format not allowed in the
> beginning .if any one have solution.pls send me

Completely untested. (Straight from brain to keyboard, so you will
have to debug.) Not sure I understand #3 correctly, but if you *want*
to match two letters followed by one or more alpha-numerics,
something like this should work, but again, untested..

   validates_length_of :whatever, :within => 5..15, :on
=> :create, :message => "must be between 5 and 15 characters long"
   validates_format_of :whatever, :with => %r{\A[a-zA-Z]{2}\w+
\Z}, :message => "must be blah blah blah."

Good luck.

Preston
C0fa318a0b78f872fd5f3151ee31132f?d=identicon&s=25 Shiva Shiva (shiva_98)
on 2007-03-20 06:37
thans buddy
This topic is locked and can not be replied to.