Regex corresponds to TR3456789, ME3456789 or 123456789

I am trying to create a regex that matches any of the following values:

  • TR3456789
  • ME3456789
  • 123456789

Rule: Any line in which the first two characters are "ME", "TR" or 2 numbers, and the last 7 characters are numbers.

(\bME\b|\bTR\b|[0-9]{2})[0-9]{7}

I cannot make my regular expression match all parameters. Any regular expression gurus that can help me?

+4
source share
3 answers

The regular expression will be: (ME|TR|[0-9]{2})[0-9]{7}

+4
source

This is my example /^(ME|TR|\d{2})\d{7}$/, and here you can try.

+4
source

\b ME TE. , - . \b , .

\b(ME|TR|[0-9]{2})[0-9]{7}\b
+1
source

Source: https://habr.com/ru/post/1662690/


All Articles