Regex to match card code input

Posted by kate on Stack Overflow See other posts from Stack Overflow or by kate
Published on 2010-04-10T19:58:48Z Indexed on 2010/04/11 3:23 UTC
Read the original article Hit count: 293

Filed under:
|

How can I write a regex to match strings following these rules?

  • 1 letter followed by 4 letters or numbers, then
  • 5 letters or numbers, then
  • 3 letters or numbers followed by a number and one of the following signs: ! & @ ?

I need to allow input as a 15-character string or as 3 groups of 5 chars separated by one space.

I'm implementing this in JavaScript.

© Stack Overflow or respective owner

Related posts about regex

Related posts about JavaScript