This works for java's regular expression parser.

^\d{15}+$|^(\d{4}\s){3}+\d{4}$|^(\d{4}\-){3}+\d{4}$

This translates as
^\d{15}+$                           exactly 15 digits 
|                                         or
^(\d{4}\s){3}+\d{4}$           the string starts with exactly 3 groups of 4 
digits followed by a white space char followed by 4 digits
|                                         or
^(\d{4}\-){3}+\d{4}$           the string starts with exactly 3 groups of 4 
digits followed by a '-' char followed by 4 digits

> Date: Tue, 9 Sep 2008 03:40:03 -0300
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: [rails-development] Active Record homework regex
> 
> 
> Hi,
> 
> Can someone give me a hand on the validation of the credit card format
> for the homework of the Active Record lesson?
> It says:
> # User can enter the credit card format in the following format.  The
> x has to be numeric value.
>     * xxxx-xxxx-xxxx-xxxx  (format #1)
>     * xxxx xxxx xxxx xxxx (format #2)
>     * xxxxxxxxxxxxxxxx (format #3)
> If someone could write the regex for it nicely that would be very helpful.
> 
> Regards,
> Vanessa
> 
> > 

_________________________________________________________________
Stay up to date on your PC, the Web, and your mobile phone with Windows Live.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093185mrt/direct/01/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to