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

[eluser]Pygon[/eluser]
I don't think it has to do with "over-engineering". 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.

"Simplicity", in the form of one-line functions, doesn't necessarily mean it is the best solution. Regex is great but takes it's toll on the CPU. String manipulation uses far less CPU, and is often the same speed or faster. My function is limited in scope as to just masking any card that is entered (provided there are atleast 4 numbers). A more functional solution would be a seperate function which strips all formatting, allowing one variable (containing the card number after being stripped) to be used for multiple things like:
simple form verification - strlen(16)
pre-auth - no need to strip formatting, again.
billing - same as above
receipt(masking) - same as above

One regex versus many is always better. Why waste more CPU cycles maintaining a user's input rather than spending them on something of use.

Our goal, as web developers, is to unrestrict users (by not forcing them to follow standards), while enforcing standards internally for speed, maintenance and operations. Approaching anything with "just do something that works, there are more important things" breeds future problems--always. Have a read through WorseThanFailure if you think otherwise.


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