const regex = /^\+?([87](?!95[5-79]|99[08]|907|94[^0]|336)([348]\d|9[0-6789]|7[01247])\d{8}|[1246]\d{9,13}|68\d{7}|5[1-46-9]\d{8,12}|55[1-9]\d{9}|55[138]\d{10}|55[1256][14679]9\d{8}|554399\d{7}|500[56]\d{4}|5016\d{6}|5068\d{7}|502[45]\d{7}|5037\d{7}|50[4567]\d{8}|50855\d{4}|509[34]\d{7}|376\d{6}|855\d{8,9}|856\d{10}|85[0-4789]\d{8,10}|8[68]\d{10,11}|8[14]\d{10}|82\d{9,10}|852\d{8}|90\d{10}|96(0[79]|17[0189]|181|13)\d{6}|96[23]\d{9}|964\d{10}|96(5[569]|89)\d{7}|96(65|77)\d{8}|92[023]\d{9}|91[1879]\d{9}|9[34]7\d{8}|959\d{7,9}|989\d{9}|971\d{8,9}|97[02-9]\d{7,11}|99[^4568]\d{7, 11}|994\d{9}|9955\d{8}|996[2579]\d{8}|9989\d{8}|380[345679]\d{8}|381\d{9}|38[57]\d{8,9}|375[234]\d{8}|372\d{7,8}|37[0-4]\d{8}|37[6-9]\d{7,11}|30[69]\d{9}|506\d{9}|386\d{9}|965\d{9}|373\d{9}|856\d{9}|371\d{9}|996\d{9}|507\d{9}|509\d{9}|502\d{9}|374\d{9}|375\d{9}|95\d{10}|966\d{9}|503\d{9}|505\d{9}|501\d{9}|961\d{9}|389\d{9}|370\d{9}|93\d{10}|34[67]\d{8}|998\d{9}|993\d{9}|992\d{9}|968\d{9}|3459\d{11}|7\d{11}|967\d{9}|92\d{10}|964\d{9}|98\d{10}|34\d{10}|94\d{10}|372\d{9}|380\d{9}|995\d{9}|30\d{10}|960\d{9}|3[12359]\d{8,12}|36\d{9,10}|38[169]\d{8}|382\d{8,9}|46719\d{10})$/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^\\+?([87](?!95[5-79]|99[08]|907|94[^0]|336)([348]\\d|9[0-6789]|7[01247])\\d{8}|[1246]\\d{9,13}|68\\d{7}|5[1-46-9]\\d{8,12}|55[1-9]\\d{9}|55[138]\\d{10}|55[1256][14679]9\\d{8}|554399\\d{7}|500[56]\\d{4}|5016\\d{6}|5068\\d{7}|502[45]\\d{7}|5037\\d{7}|50[4567]\\d{8}|50855\\d{4}|509[34]\\d{7}|376\\d{6}|855\\d{8,9}|856\\d{10}|85[0-4789]\\d{8,10}|8[68]\\d{10,11}|8[14]\\d{10}|82\\d{9,10}|852\\d{8}|90\\d{10}|96(0[79]|17[0189]|181|13)\\d{6}|96[23]\\d{9}|964\\d{10}|96(5[569]|89)\\d{7}|96(65|77)\\d{8}|92[023]\\d{9}|91[1879]\\d{9}|9[34]7\\d{8}|959\\d{7,9}|989\\d{9}|971\\d{8,9}|97[02-9]\\d{7,11}|99[^4568]\\d{7, 11}|994\\d{9}|9955\\d{8}|996[2579]\\d{8}|9989\\d{8}|380[345679]\\d{8}|381\\d{9}|38[57]\\d{8,9}|375[234]\\d{8}|372\\d{7,8}|37[0-4]\\d{8}|37[6-9]\\d{7,11}|30[69]\\d{9}|506\\d{9}|386\\d{9}|965\\d{9}|373\\d{9}|856\\d{9}|371\\d{9}|996\\d{9}|507\\d{9}|509\\d{9}|502\\d{9}|374\\d{9}|375\\d{9}|95\\d{10}|966\\d{9}|503\\d{9}|505\\d{9}|501\\d{9}|961\\d{9}|389\\d{9}|370\\d{9}|93\\d{10}|34[67]\\d{8}|998\\d{9}|993\\d{9}|992\\d{9}|968\\d{9}|3459\\d{11}|7\\d{11}|967\\d{9}|92\\d{10}|964\\d{9}|98\\d{10}|34\\d{10}|94\\d{10}|372\\d{9}|380\\d{9}|995\\d{9}|30\\d{10}|960\\d{9}|3[12359]\\d{8,12}|36\\d{9,10}|38[169]\\d{8}|382\\d{8,9}|46719\\d{10})$', '')
const str = ``;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions