Satisfies all your requirements if you use the trick told below
Regex: /^(+d{1,3}[- ]?)?d{10}$/
^
start of line
- A
+
followed by d+
followed by a
or -
which are optional.
- Whole point two is optional.
- Negative lookahead to make sure
0
s do not follow.
- Match
d+
10 times.
- Line end.
DEMO Added m
ultiline flag in demo to check for all cases
P.S. You really need to specify which language you use so as to use an if
condition something like below:
// true if above regex is satisfied and (&&) it does not (`!`) match `0`s `5` or more times
if(number.match(/^(+d{1,3}[- ]?)?d{10}$/) && ! (number.match(/0{5,}/)) )
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…