Matches valid credit card numbers with a valid Luhn checksum in all varieties:
Use the following expression to parse credit card numbers:
CREDITCARD:result
For example, parsing credit card numbers in different formats:
| Description | input (string) | result (long) |
|---|---|---|
Continuous digits (Amex) |
|
|
Continuous digits (Diners Club) |
|
|
Continuous digits (Mastercard) |
|
|
Continuous digits (Discover) |
|
|
Space-delimited (Amex, 3 groups) |
|
|
Space-delimited (Diners Club, 3 groups) |
|
|
Space-delimited (Visa, 4 groups) |
|
|
Space-delimited (Mastercard, 4 groups) |
|
|
Space-delimited (Discover, 4 groups) |
|
|
Dash-delimited (Amex) |
|
|
Dash-delimited (Diners Club) |
|
|
Dash-delimited (Visa) |
|
|
Mixed dash and space (Visa) |
|
|
Mixed space and dash (Visa) |
|
|
URL-encoded spaces |
|
|
Invalid delimiter (dot) |
|
|
Invalid length — too short |
|
|
Valid length, invalid Luhn |
|
|
Surrounded by non-digit characters |
|
|
Extra trailing digit |
|
|
data record(input = "378282246310005"),record(input = "36227206271667"),record(input = "5500005555555559"),record(input = "6011111111111117"),record(input = "3782 822463 10005"),record(input = "3622 720627 1667"),record(input = "4111 1111 1111 1111"),record(input = "5500 0055 5555 5559"),record(input = "6011 1111 1111 1117"),record(input = "3782-822463-10005"),record(input = "3056-930902-5904"),record(input = "4916-3385-0608-2832"),record(input = "4916-3385 0608 2832"),record(input = "4916 3385-0608 2832"),record(input = "4917%206100%200000%200000%20003"),record(input = "4916.3385.0608.2832"),record(input = "411111111111"),record(input = "4111111111111112"),record(input = "X4111111111111111X"),record(input = "41111111111111117")| parse input, "CREDITCARD:result"
The data type of the extracted value is long.
Given the following input:
txId=a1b2 card=4111111111111111
Use the following expression to extract the credit card number:
DATA CREDITCARD:result
result (long) |
|---|
|
data record(input = "txId=a1b2 card=4111111111111111")| parse input, "DATA CREDITCARD:result"
Given the following input:
[2026-04-13] user=johndoe card=3782 822463 10005 action=checkout
Use CREDITCARD to capture the number, then replacePattern to overwrite all but the last four digits with X, masking the sensitive data while preserving the record structure:
DATA CREDITCARD:ccno
The replacePattern function locates the credit card number with the CREDITCARD matcher and substitutes the masked value built from the captured ccno:
result (string) |
|---|
|
data record(input = "[2026-04-13] user=johndoe card=3782 822463 10005 action=checkout")| parse input, "DATA CREDITCARD:ccno"| fieldsAdd result = replacePattern(input, "CREDITCARD", concat("XXXXXXXXXXX", substring(toString(ccno), from: -4)))