Regular expression for xxxx.xxx.xxx

I need to check the vat number.

xxxx.xxx.xxx → 0123.456.789 - a valid number.

I found a regex

^(BE)[0-1]{1}[0-9]{9}$|^((BE)|(BE ))[0-1]{1}(\d{3})([.]{1})(\d{3})([.]{1})(\d{3})

This will confirm the following entry: BE 0123.456.789.

But I only need to check xxxx.xxx.xxx (nothing is invalid, only this)

So 4 digits, dot, 3 digits, dot, 3 digits.

It should also start with 0 or 1 (first x → 0 or 1)

+3
source share
7 answers

This should work:

^[01]\d{3}\.\d{3}\.\d{3}$
+6
source

Here you go:

^[01]\d{3}\.\d{3}\.\d{3}$

Structure:

^      - Start of string
[01]   - Followed by a 0 or 1
\d{3}  - Followed by three numerals
\.     - Followed by a .
\d{3}  - Followed by three numerals
\.     - Followed by a .
\d{3}  - Followed by three numerals
$      - Followed by end of string
+4
source

^[0-1]\d{3}[.]\d{3}[.]\d{3}$

^     // start of the input
\d{#} // numbers repeated # times
[.]   // literal . (same as  \.  )
$     // end of the input
+3

, : 4 digits , a point , 3 digits , a point , 3 digits. and begin with 0 or 1

:

^[01]\d{3}\.\d{3}\.\d{3}$
+3

:

^[01]\d{3}\.\d{3}\.\d{3}$
+2

,

^[01]\d{3}\.\d{3}\.\d{3}$

, ( ), \d [:digit:], , .

( ), [0-9] \d:

^[01][0-9]{3}\.[0-9]{3}\.[0-9]{3}$
+1

, , :

^[01]\d{3}\.\d{3}\.\d{3}$

, : 0 1, 3 , , 3 , , 3 . , , , BE, , , .

0

All Articles