[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regex Question

"Diego Gardel" <dgardel@hotmail.com> wrote ..
> I am working on creating a regex to match the various credit card numbering
> patterns.

Don't. Just say no. Do not re-invent the wheel.

Get Business::CreditCard from CPAN, move on, and be more productive.

Read the source code if you want to know how it was done.

Oh, and step 1 is to strip any non-numeric characters from your string.
Does it really matter if they entered 5-1-2-3-4-5-6-7... or 512----5345...?

Not unless you want to force the user to type it exactly as your program requires it. But it only requires numbers, remember? So, let them type what they want,
and do a simple s/[^0-9]//g on it. Then compare against a CC number.

BTW, why _do_ you need to identify some data as containing valid CC numbers?

There's several free libraries and SDKs around that do input validation for whatever language you're programming in: Perl, Java, PHP, C#, .NET, ASP, ...


To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.