Welcome Guest, Not a member yet? Register   Sign In
how to mask credit card number (using regex?)
#10

[eluser]untermensch[/eluser]
[quote author="Pygon" date="1194044896"]Mine is a concern for speed and enforcing standards, while allowing user input to be anything they want while still working. Should your function encounter a trailing hyphen, it would not work properly.[/quote]
Mate, have you even tried running your one above? The preg_replace is superfluos, and it strips out the hyphens, and assumes all CC numbers have 16 digits (they vary between 14 and 16).

Besides which, nobody asked about a CC number *validator*. It is assumed validation has already been done. The request was only to mask out all but the last 4 digits - so the trailing hyphen point is entirely moot (although your solution suffers from the same "problem").

[quote author="Pygon" date="1194044896"]"Simplicity", in the form of one-line functions, doesn't necessarily mean it is the best solution.[/quote]
Simplicity is readability.

[quote author="Pygon" date="1194044896"]Regex is great but takes it's toll on the CPU.[/quote]
Which makes me wonder why you have a redundant preg_replace Smile

[quote author="Pygon" date="1194044896"]My function is limited in scope as to just masking any card that is entered (provided there are atleast 4 numbers)[/quote]

Which is exactly what the original poster asked for...


Messages In This Thread
how to mask credit card number (using regex?) - by El Forum - 11-01-2007, 12:24 AM
how to mask credit card number (using regex?) - by El Forum - 11-01-2007, 12:43 AM
how to mask credit card number (using regex?) - by El Forum - 11-01-2007, 12:54 AM
how to mask credit card number (using regex?) - by El Forum - 11-01-2007, 05:46 PM
how to mask credit card number (using regex?) - by El Forum - 11-01-2007, 07:36 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 08:20 AM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 09:42 AM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 11:13 AM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 12:08 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 12:13 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 12:32 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 12:55 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 01:25 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 01:37 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 01:53 PM
how to mask credit card number (using regex?) - by El Forum - 11-02-2007, 02:35 PM
how to mask credit card number (using regex?) - by El Forum - 11-03-2007, 07:44 AM
how to mask credit card number (using regex?) - by El Forum - 11-03-2007, 12:17 PM
how to mask credit card number (using regex?) - by El Forum - 11-03-2007, 12:44 PM
how to mask credit card number (using regex?) - by El Forum - 11-03-2007, 03:51 PM
how to mask credit card number (using regex?) - by El Forum - 11-03-2007, 06:02 PM
how to mask credit card number (using regex?) - by El Forum - 04-29-2009, 04:09 AM
how to mask credit card number (using regex?) - by El Forum - 04-29-2009, 06:41 AM
how to mask credit card number (using regex?) - by El Forum - 07-23-2009, 11:36 AM
how to mask credit card number (using regex?) - by El Forum - 08-05-2009, 09:37 PM
how to mask credit card number (using regex?) - by El Forum - 06-24-2010, 10:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB