Copy regular expressions to a single click

Regular expression of Credit Cards

Regular expressions and life hacks to control the prevention and monitoring of the transfer of credit cards of payment systems Visa, Mastercard, Mir Russia in the DLP system.

Regular expression for Visa, MasterCard and Prostir.

# RegEx

(?:^|\s)(?:[4|5|6|9]\d{3})([ -]?)\d{4}\1\d{4}\1\d{4}(?:$|\s|\.|\,)

Regular expression for Visa Credit Cards.

Visa

# RegEx

(?:^|\s)(?:4\d{3})([ -]?)\d{4}\1\d{4}\1\d{4}(?:$|\s|\.|\,)

(?:^|\s) – start of string (with a new line or space)
(?:4\d{3}) – start with digit 4 and random 3 digits
([ -]?)\d{4}\1\d{4}\1\d{4} – space or dash every random 4 digits 3 times
(?:$|\s|\.|\,) – end of string (line end, space, dot, or comma)

Example:
4916 9006 6151 3107 and 4609-3639-2287-9340 and 4369559843305287

Regular expression for MasterCard.

card_master__icon

# RegEx

(?:^|\s)(?:5\d{3})([ -]?)\d{4}\1\d{4}\1\d{4}(?:$|\s|\.|\,)

(?:^|\s) – start of string (with a new line or space)
(?:5\d{3}) – start with digit 5 and random 3 digits
([ -]?)\d{4}\1\d{4}\1\d{4} – space or dash every random 4 digits 3 times
(?:$|\s|\.|\,) – end of string (line end, space, dot, or comma)

Example:
5404 3664 0602 4840 and 5404-3658-7741-3532 and 5404363072774782

Regular expression for Prostir (Ukrainian System).

prostir_icon

# RegEx

(?:^|\s)(?:[6|9]\d{3})([ -]?)\d{4}\1\d{4}\1\d{4}(?:$|\s|\.|\,)

(?:^|\s) – start of string (with a new line or space)
(?:[6|9]\d{3}) – start with digit 6/9 and random 3 digits
([ -]?)\d{4}\1\d{4}\1\d{4} – space or dash every random 4 digits 3 times
(?:$|\s|\.|\,) – end of string (line end, space, dot, or comma)

Example:
6404 3664 0602 4840 and 6404-3658-7741-3532 and 6404363072774782

9404 3664 0602 4840 and 9404-3658-7741-3532 and 9404363072774782

Regular expression for Mir (Russia).

Mir_icon

# RegEx

(?:^|\s)(?:2\d{3})([ -]?)\d{4}\1\d{4}\1\d{4}(?:$|\s|\.|\,)

(?:^|\s) – start of string (with a new line or space)
(?:2\d{3}) – start with digit 2 and random 3 digits
([ -]?)\d{4}\1\d{4}\1\d{4} – space or dash every random 4 digits 3 times
(?:$|\s|\.|\,) – end of string (line end, space, dot, or comma)

Example:
2404 3664 0602 4840 and 2404-3658-7741-3532 and 2404363072774782