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.
regex101.com is a great regex calculator. Use it to find a suitable regex and give it a test before using it in PaperCut. In the “Flavor” section, select Java 8.
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.
Comments
0 comments
Please sign in to leave a comment.