I have created a regex for validating a telephone number with following requirement:
Allowed chars:
+ space ( ) – 0-9
+
or(
can be first char after trim like(+61) 312 405 678
or+61 312 405 678
.Dash is allowed anywhere in the number.
Length min 8 max 16 – show error in case of boundary conditions
But I need to enhance it a bit. I want to validate that if +
is in the number it must be only in the beginning but my regex is not checking this. Please help. This is my regex so far:
^[\\(?\\+?(\\d{2})\\)?[- ]?(\\d{0,})[- ]?(\\d{0,})[- ]?(\\d{0,})]{9,16}$