简体   繁体   中英

Serbia Mobile Telephone Regex

I am looking for editing my serbia Mobile Telephone Regex. Mobile Number begin with 60, 61, 62, 63, 64, 65, 66, 68, 69, 677, 678
https://en.wikipedia.org/wiki/Telephone_numbers_in_Serbia#Mobile_telephony

What can be the right regex for nine digits number of above pattern with or without space or comma and with or without international code +381

Looking for something better than (\\d{3}) \\d{3}-\\d{3}

Assume that the mobile number is of 10 digit without country code.
If not, change the values of \\d{8} and \\d{7} accordingly.
That is if length is X , put \\d{X-2} and \\d{X-3}

 //Mobile Number begin with 60, 61, 62, 63, 64, 65, 66, 68, 69, 677, 678 // +381 var re = /^(\\+381)?(\\s|-)?6(([0-6]|[8-9])\\d{8}|(77|78)\\d{7}){1}$/ console.log(re.test('+381-6812345678')); // hyphen console.log(re.test('+381 6812345678')); // space console.log(re.test('+3816812345678')); // without seperator console.log(re.test('+381-7812345678')); //start with 7->false console.log(re.test('+381-6772345678')); //start in 677->true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM