Re: Looking for a certain regexp
From: Dale Henderson (nilram_at_hotpop.com)
Date: 06/30/04
- Next message: Bryan Castillo: "Re: limitations of forking on windows"
- Previous message: gnari: "Re: HTTP::Request, trailing slash"
- Next in thread: John Bokma: "Re: Looking for a certain regexp"
- Reply: John Bokma: "Re: Looking for a certain regexp"
- Reply: Purl Gurl: "Re: Looking for a certain regexp"
- Reply: Dale Henderson: "Re: Looking for a certain regexp"
- Reply: Anno Siegel: "Re: Looking for a certain regexp"
- Maybe reply: Dale Henderson: "Re: Looking for a certain regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jun 2004 15:57:34 -0500
>>>>> "PG" == Purl Gurl <purlgurl@purlgurl.net> writes:
PG> Abigail wrote:
>> Checksums *can* be checked with a regexp.
PG> No, they cannot and returns are not a checksum, both within a
PG> context of credit card number validation.
PG> Returns are based on a mathematical formula which should
PG> return zero for modulus ten if a valid number.
The Luhn or "mod 10" formula is essentially a checksum.
Is just that you know the sum ahead of time i.e. 0.
PG> You cannot use a regex for validating credit card numbers.
I wouldn't be so quick to say what can't be done with a regular
expression. Regular expressions (especially Perl regular
expressions) are very powerful and can even be
used to check numbers for primality tests and even solve simple
Diophantine equations.
For example to test for primality use:
$p=7; #number to test for primality
$str="1"x$p;
if(str=~/^(11+)\1+$/){
print "$p is Composite\n";
}else{
print "$p is Prime\n"
}
Not an efficient test but it works none the less.
In fact the first step of the Luhn test can be done with:
$cc=1234567890123456
$cc=~s/(\d)(\d)/(x==9?9:($1*2)%9).$2/eg;
This assumes the length of $cc is even (for odd length a
different replacement is needed) and doubles the odd numbered
digits with appropriate modifications (add the digits of 2 digit
numbers).
For the next step putting a plus between the digits and using an
eval would work.
>> Now, if only I could find the URLs with the checksum formulas
PG> Too bad you have me killfiled. You could learn from me, just
PG> as I learn from others. I have almost a decade of experience
PG> in working with credit card validation.
PG> http://www.beachnet.com/~hstiles/cardtype.html
PG> Others will learn from what I share. You will not. In time,
PG> others will know more than you, just as I know more about this
PG> topic than you. It is illogical to limit your ability to gain
PG> knowledge based upon personal bigotry.
PG> Fix your quoting style; it is as bad as Uri's and Randal's and
PG> a real chore to repair. Wastes bandwidth to boot.
How dare you harass Abigail just because she is female. :)
PG> Purl Gurl
-- Dale Henderson "Imaginary universes are so much more beautiful than this stupidly- constructed 'real' one..." -- G. H. Hardy
- Next message: Bryan Castillo: "Re: limitations of forking on windows"
- Previous message: gnari: "Re: HTTP::Request, trailing slash"
- Next in thread: John Bokma: "Re: Looking for a certain regexp"
- Reply: John Bokma: "Re: Looking for a certain regexp"
- Reply: Purl Gurl: "Re: Looking for a certain regexp"
- Reply: Dale Henderson: "Re: Looking for a certain regexp"
- Reply: Anno Siegel: "Re: Looking for a certain regexp"
- Maybe reply: Dale Henderson: "Re: Looking for a certain regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|