Skip to content

Instantly share code, notes, and snippets.

@jeffangelion
Last active May 15, 2021 07:23
Show Gist options
  • Save jeffangelion/fea9a81af35c690f95201584b5cac075 to your computer and use it in GitHub Desktop.
Save jeffangelion/fea9a81af35c690f95201584b5cac075 to your computer and use it in GitHub Desktop.
Regex for InfoWatch(c) Traffic Monitor(c)

Regular expressions handbook for InfoWatch(c) Traffic Monitor(c)

Written using this doc

1. Numbers from one hundred to two billions (including)

Every three digits divided by dot

(2(\.0{3}){3})|(1(\.\d{3}){3})|([1-9]\d{0,2}(\.\d{3}){1,2})|([1-9]\d{2})

Explanations (from verti-bar to verti-bar)

  • two billions itself
  • from one billion to one billion nine hundred ninety nine thousand nine hundred ninety nine
  • from one thousand to nine hundred ninety nine thousand nine hundred ninety nine
  • from one hundred to nine hundred ninety nine

2. IPv4 addresses

First three octets including dot after each of them

((2((5[0-5])|([0-4]\d))|(1?\d{1,2}))\.){3}(2((5[0-5])|([0-4]\d))|(1?\d{1,2}))

Explanations (from verti-bar to verti-bar)

  • octets from 200 to 255
  • octets from 0 to 199

3. Russian mobile (or three-digit landline) phone numbers

(\+7|8)(\s)?(\()?(\d{3})\)?(\s|-)?(\d{3})(\s|-)?(\d{2})(\s|-)?(\d{2})

Explanations (from bracket to bracket)

  • international (+7) or local (8) digit
  • three-digit mobile operator (or city) code (can be framed by brackets)
  • seven numbers divided (or not) by hyphen or space Number parts can also be divided by spaces

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