I'm having no end of trouble coming up with an appropriate regex or set of regex's.
What I want to do is detect:
- Detect contineous run of digits of length 13 through 19
- Detect contineous run of digits interspersed with whitespace of length 13 through 19
- Detect contineous run of digits interspersed with dashes of length 13 through 19
The basic business requirement is to warn a user that they may have entered a credit card number in a text field and they ought not to do that (though only a warning, not a hard error). The text field could span multiple lines, could be up to 8k long, a CC # could be embedded anywhere (unlikely to split across multiple lines), could be more than 1 CC# (though detecting the prescence of at least 1 is all I need. I don't need the actual value). Don't need to validate check digit.
The length check can be done external... ie I'm happy to loop through a set of matches, drop any whitespace/dashes and then do a length comparison.
But... JavaScript regex is defeating my every attempt (just not in the right "head space") so I thought I'd ask here :)
Thanks!