Skip to content

Instantly share code, notes, and snippets.

@jeffangelion
Last active May 15, 2021 07:22
Show Gist options
  • Save jeffangelion/91ed5b1d55f9c62f20d88fcd9989db4a to your computer and use it in GitHub Desktop.
Save jeffangelion/91ed5b1d55f9c62f20d88fcd9989db4a to your computer and use it in GitHub Desktop.
Regex written just for fun

Short link: https://git.io/JsZ62

Serious regexes: https://gist.github.com/jeffangelion/fea9a81af35c690f95201584b5cac075

1. Rocket code names (in case you are working for Ministry of Defence)

((Р((\d{0,4}[А-Я]{1,2})|(\d{1,4}[А-Я]{0,2})))|(Р-\d{1,4}-?[А-Я]{1,2}))[\s]+

Match tests:

Value Should match?
Р-1111-АА Yes
Р-1-А Yes
Р1А Yes
Р-1А Yes
Р1-А No
Р1 Yes
РА Yes
Р No
Р- No

2. Demo email detect

[_\w\d][_\+\-\.\w\d]{0,62}[_\w\d]?@(demo|демо)\.[\w]{2,}

Match tests: later


3. Logistic order IDs

[A-z]{3}-(1000|[7-9]\d{2}|6([7-9]\d|6([0-5]|[7-9])|[0-5]\d)|[1-5]\d{2}|[2-9]\d|1([0-2]|[4-9])|\d)-[А-ЯЁ]

Match tests: WIP

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