Skip to content

Instantly share code, notes, and snippets.

@SHi-ON
Last active July 21, 2021 15:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SHi-ON/b2ae4100f50b2e2d96ff8277632cc325 to your computer and use it in GitHub Desktop.
Save SHi-ON/b2ae4100f50b2e2d96ff8277632cc325 to your computer and use it in GitHub Desktop.
specific-length formatted numbers

(?<!\d)([0-9]{5}-[0-9]{4}-[0-9]{2})(?!\d)

Explained:

  • ?> lookbehind
  • ?<! negative lookbehind
  • \d digit only
  • ? lookahead
  • ?! negative lookahead
  • [0-9]{5}-[0-9]{4}-[0-9]{2} a specific pattern #####-####-##

For a code-highlighted view take a peek at this RegExr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment