Regular Expressions for Card Numbers

KB Home   |   Regular Expressions for Card Numbers

Main.RegularExpressionsForCardNumbers History

Hide minor edits - Show changes to output

July 12, 2018, at 12:02 AM by Aaron Pouliot - Added category identification
Changed line 24 from:
''Categories:''
to:
''Categories:'' [[Category.Identification|+]]
Changed line 20 from:
->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 [[https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.htmll|detailed information]] about the Java regex engine that PaperCut uses.
to:
->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 [[https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html|detailed information]] about the Java regex engine that PaperCut uses.
September 13, 2017, at 03:43 AM by Alec - Update to Java 8 docs
Changed line 20 from:
->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 [[http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html|detailed information]] about the Java regex engine that PaperCut uses.
to:
->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 [[https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.htmll|detailed information]] about the Java regex engine that PaperCut uses.
April 23, 2015, at 03:39 AM by Alec - Add help link for Chrome Users
Changed lines 21-22 from:
 
to:

Having trouble seeing the applet in the Google Chrome browser? You may find help [[https://java.com/en/download/faq/chrome.xml| here]].
Changed line 20 from:
->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})@@").
to:
->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 [[http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html|detailed information]] about the Java regex engine that PaperCut uses.
Changed line 20 from:
->If your string contains an optional group of characters at the start (e.g. "@@;?0?(\d{8})@@") then try and use the start of string anchor "@@^@@" and a non capturing group (so our previous example becomes "@@^(?:;0)?(\d{8})@@").
to:
->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})@@").
Changed lines 20-21 from:
->If your string contains optional characters at the start (e.g. ";?0?(\d{8})") then try and use the start of string anchor "^" (so our previous example becomes "^;?0?(\d{8})").
to:
->If your string contains an optional group of characters at the start (e.g. "@@;?0?(\d{8})@@") then try and use the start of string anchor "@@^@@" and a non capturing group (so our previous example becomes "@@^(?:;0)?(\d{8})@@").
 
Changed lines 20-21 from:
->If your string contains optional characters at the start (e.g. ";?0?") then try and use the start of string anchor "^" (so our previous example becomes "^;?0?")
to:
->If your string contains optional characters at the start (e.g. ";?0?(\d{8})") then try and use the start of string anchor "^" (so our previous example becomes "^;?0?(\d{8})").
Changed line 25 from:
[-Keywords: card regex, change card number-]
to:
[-Keywords: card regex, change card number-]
November 13, 2012, at 11:15 PM by Alec - Added a tip
Added lines 18-21:
!!!Handy tip

->If your string contains optional characters at the start (e.g. ";?0?") then try and use the start of string anchor "^" (so our previous example becomes "^;?0?")

Changed lines 3-4 from:
TODO
to:
Regular expressions ('''regex'''es) 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.

Added lines 11-17:
!!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!

Added lines 1-10:
(:title Regular Expressions for Card Numbers:)

TODO

(:include_html_CardRegexHelper:)

----
''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 July 12, 2018, at 12:02 AM
Printable View   |   Article History   |   Edit Article