Regular Expressions for Card Numbers

KB Home   |   Regular Expressions for Card Numbers

Regular expressions (regexes) are used in several places in PaperCut, including with card numbers. Regexes are applied to card data to extract a useful card number. The raw data read from a card may contain multiple numbers (of which just one is required), extra information like a “site code” or “checksum”, or additional characters designed as special markers or to separate multiple fields.

There are many different card formats out there so there is no “one size fits all”. Rather, an appropriate regex should be used to extract the useful number for PaperCut to use.

The tool below can help to choose a suitable regex. See below for usage help.

Please install Java to use the card regex helper.

Recommended usage

1. Look at list of included examples to see if any match your need.
2. Obtain a test card number. E.g. plug a card reader into a computer, open a text editor and swipe the card. Copy the test card number into the “Card Number” field.
3. Enter a regex that results in the match you expect.
4. Try the same regex with a few more card numbers to make sure it’s working how you expect.
5. Copy the regex, store it for safe keeping, use it in PaperCut!

Handy tip

If your string contains an optional group of characters at the start (e.g. “;?0?(\d{8})”, where the second character could also match the following \d) then try and use the start of string anchor “^” and a non capturing group (so our previous example becomes “^(?:;0)?(\d{8})”). Oracle supply detailed information about the Java regex engine that PaperCut uses.

Having trouble seeing the applet in the Google Chrome browser? You may find help here.


Categories:


Keywords: card regex, change card number

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on September 13, 2017, at 03:43 AM
Printable View   |   Article History   |   Edit Article