I'm trying to create a regular expression that would validate a specific phone number with an 868 area code and particular format h thus I want these
8680000000
(868) 000 0000
868-000-0000
868 000-0000
to pass validation but these
8880000000
767-000-0000
868-0000000
(868)0000000
to fail validation.
So far I got:
^((\(){0,1}(868){1}(\)){0,1})+:?((((\ |\-)(\d{3})(\ |\-)):?\d{4})+|(\d{4,7}))
But
(868)0000000
is validating
Actually this is somewhat hard-coded because you are having some specific requirements like validating
868-000-0000
but not868-0000000
.Regex is:
DEMO