Regular expressions for card login

You can allow users to login using an alpha-numeric code that conforms to a known pattern such as a library card number.

To validate the card number as valid it must conform to a Regular Expression, which you as the licence administrator must define. A "Regular Expression" is used to determine valid card patterns. Some example patterns, and their corresponding regular expressions, are shown below.

  1. 'ABC' followed by 8 numbers between '0' and '5' followed by 'Z'
    Regular expression: ABC[0-5]{8}Z
    Valid card numbers: ABC12345123Z; ABC11112222Z

  2. Four numbers between '0' and '9' followed by any four characters between 'A' and 'Z' four times
    Regular expression: [0-9]{4}[A-Z]{4}
    Valid card numbers: 1234ABCD; 1111ZZZZ

  3. A number between '0' and '2' at least 3 times and no more than 5 times
    Regular expression: [0-2]{3,5}
    Valid card numbers: 012; 0122; 01210

  4. Four numbers in the range '1', '2' or '3' followed by any one of 'A', 'B', or 'Z'
    Regular expression: [123]{4}[ABC]
    Valid card numbers: 111A; 123B; 123C

  5. Either four numbers between '1' and '3' OR five characters between 'A' and 'C'
    Regular expression: ([123]{4})|([ABC]{5})
    Valid card numbers: 1111; 1232; ABABC

Fixed characters in set positions in the pattern are included as they are (e.g. 'ABC', 'Z' in the first expression).

A range of acceptable characters can be defined by square brackets [ ] (e.g. '0-5' in the first expression; 'ABC' in the fourth expression).

The number of consecutive positions occupied by those characters is defined by curly brackets { }. If this is omitted a single character is assumed. (e.g. '8' in the first expression, omitted in the fourth expression).

For those familiar with regular expressions, start and end characters ($ & ^) are not needed.

If you have more than one card range see example 5 for how to enter two different ranges. The | character means 'or' (and can be copied and pasted if not found on your keyboard). This approach can be used to define as many ranges as required.

Log in to Who Else Writes Like...?

If you already have a Who Else Writes Like...? account you can sign in below.

Sign in now

Try Who Else Writes Like...? for FREE!

Sign up for an individual account and experience two weeks FREE access to Who Else Writes Like...?

No obligation to continue. No card details required!

Sign up for a free trial today »