Basement code forms a trap, as @ellak points out:
/^((00)|(\+))961((\d)|(7[0168]))\d{6}$/.test("009617612345");
Here the code should look like this: 00 961 76 12345 ,
but RegEx practically breaks it down like this: 00 961 7 612345 , because 7 matches in \d , and the rest is combined exactly 6 digits and matched.
I'm not sure if this is really true, but I think this is not what you want, otherwise RegEx should work in your question.
Here is a long RegEx that avoids the trap:
/^(00|\+)961([0-68-9]\d{6}|7[234579]\d{5}|7[0168]\d{6})$/
A few test results:
/(00|\+)961([0-68-9]\d{6}|7[234579]\d{5}|7[0168]\d{6})/.test("009617012345") false /(00|\+)961([0-68-9]\d{6}|7[234579]\d{5}|7[0168]\d{6})/.test("009618012345") true /(00|\+)961([0-68-9]\d{6}|7[234579]\d{5}|7[0168]\d{6})/.test("009617612345") false /(00|\+)961([0-68-9]\d{6}|7[234579]\d{5}|7[0168]\d{6})/.test("0096176123456") true
source share