I want a regex-pattern for my phone number validator.
It has to allow digits, +
, (
, )
and -
.
The restrictions are:
- The
+
needs to be at the beginning of the output (something like: "+31(427)-103819" needs to be valid) - The
+
,(
,)
and-
are not required - The output has to end with a digit
- No restrictions on length is required
Hope somebody can make me a regex for this, I have looked at different generators and ended up with something like this:
/^(\\+)*(\\d+)(\\()*(\\d+)(\\))*(-)*(\\d+)$/
This does not do what I want. Some example numbers that have to be valid:
- 190138190
- 103-10381-390101
- (0358)-103810381
- (1038)1038103
- +1081(1081)-193810
- +1903(3913)193810