Skip to content

Instantly share code, notes, and snippets.

@kpol
Created May 14, 2020 08:10
Show Gist options
  • Save kpol/293a40363a3f53ab335a96708b150b33 to your computer and use it in GitHub Desktop.
Save kpol/293a40363a3f53ab335a96708b150b33 to your computer and use it in GitHub Desktop.
(?x)
(?<![0-9])
(?:
[0-9]{12,19} # sequence of digits in the text between [12, 19] length
|
(?:[0-9]{4}[ -]){4}[0-9]{3} # 4-4-4-4-3 pattern
|
(?:[0-9]{4}[ -]){3}[0-9]{4} # 4-4-4-4 pattern
|
(?:[0-9]{4}[ -]){2}[0-9]{5} # 4-4-5 pattern
|
[0-9]{4}[ -][0-9]{6}[ -][0-9]{4,5} # 4-6-4 or 4-6-5 pattern
|
[0-9]{4}[ -][0-9]{5}[ -][0-9]{6} # 4-5-6 pattern
|
[0-9]{6}[ -][0-9]{13} # 6-13 pattern
)
(?![0-9])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment