[eluser]untermensch[/eluser]
[quote author="Pygon" date="1194046367"]The regex I gave is not superfluos[sic] as you put it[/quote]
Like I said, try running it. All you're doing with that is stripping off the first character of the line if it happens to be a number. You *probably* meant to strip out all non-digit chars, but that would change the format of the credit card, and the poster clearly wanted something in the form of XXXX-XXXX-XXXX-1234.
Quote:Superfluous would be your replacement of letters and and symbols as well as numbers, except "- ", the addition of yet another regex to verify the user input
Hello there! That's *exactly* what the poster asked for! Your regex *attempted* to strip input, which is redundant considering the point about validation and considering coolfactor asked not to assume the number should be in any specific format. The regex you call redundant is the entire business end of the solution.
Quote:FYI, your function is 100% slower even when I correct mine for an strlen of the stripped input. 
Ok, this is a really laughable point. Rule #1 of Optimisation: optimise where it will make a difference. If you are masking millions of CC numbers per minute, fair enough; I'd also look to optimise - by writing the bastard in C!
But that's an entirely ridiculous thing to be doing in this context, and I'm talking as someone who spent years handcoding machine code to get the fastest inner loops on various games consoles, and embedded systems.
(besides, my benchmarks show me mine is actually 38% slower)