Reg: regular expression


#1

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


#2

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


#3

thans buddy