Regular Expression

Seems to be working fine so far, i will keep testing for more combinations and shall update this thread if i encounter an issue

many thanks for your help

Hi there,

It’ll work fine for the conditions we have specified.
It just seemed a little hacky to me, so I wondered if there was a more elegant way of doing it.

^(?:\+(?!0)|00)[1-9]\d{10,15}$

Seems fine to me apart from I think (?!0) is redundant now? So:

^(?:\+|00)[1-9]\d{10,15}$

Oh yeah, good one.
That was there to make sure that the plus was not followed by a zero, which after the latest modification it won’t be anyway.

or:

^(?:\+|00)(?!0)\d{11,16}$

Yup, that’s much easier to read.

Hi

Anything wrong in the following?

^(?:\+|00)[1-9][0-9]{10,15}$

No, not really.
You should however be aware that writing \d, is the same as writing [0-9].

means \d is faster than [0-9] ?

Nope, just more concise.

Hi Again

I am using the following regex:

/^(?:\\+|00)[1-9][0-9]{10,15}$/

But it does not validate the following two numbers, any idea why?

005374152368
+4865718575

Thanks

Your original post says the numbers should be between 11 - 16 chars (length excluding + and 00). These numbers are only 10 chars.