From what I can see, this should work. The prefix is optional and is stored into the first match group, with the main number going into the second group.

^([0|\+[0-9]{1,5})?([7-9][0-9]{9})$

But if you can give us some test cases for each, it'd help us in giving you a working regex for what you want.

Props to SchlaWiener in the comments for the correct limit on the country code length.

Answer from Joe on Stack Overflow
๐ŸŒ
UI Bakery
uibakery.io โ€บ regex-library โ€บ phone-number
Phone number regex
Most important things to know about Phone number regex and examples of validation and extraction of Phone number from a given string in JavaScript programming language.
Discussions

Javascript Regex - What to use to validate a phone number? - Stack Overflow
Could anyone tell me what RegEx would work to validate an international phone number including white space between the numbers and also allowing for these chars: - ( ). The amount of numbers in the More on stackoverflow.com
๐ŸŒ stackoverflow.com
regex - Regular Expression to reformat a US phone number in Javascript - Stack Overflow
I'm looking to reformat (replace, not validate - there are many references for validating) a phone number for display in Javascript. Here's an example of some of the data: 123 4567890 (123) 456-789... More on stackoverflow.com
๐ŸŒ stackoverflow.com
validation - RegEx for valid international mobile phone number - Stack Overflow
I use Clickatell to send SMSes to clients' mobile phones. Is there a standardised regular expression for all valid mobile phone numbers, e.g. +27 123 4567? I'd roll my own, but I'm worried about m... More on stackoverflow.com
๐ŸŒ stackoverflow.com
javascript - How to format mobile phone number with country code using regex - Stack Overflow
I have been trying to format properly the phone number so that all country can use at least. I am trying to use this format to accept as many regions as possible Here is my pattern $pattern = '^\+[... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ dsa โ€บ validate-phone-numbers-with-country-code-extension-using-regular-expression
Validate Phone Numbers ( with Country Code extension) using Regular Expression - GeeksforGeeks
July 23, 2025 - Given some Phone Numbers, the task is to check if they are valid or not using regular expressions. Rules for the valid phone numbers are: ... It should be followed by Country code and National number.
๐ŸŒ
Voximplant
voximplant.com โ€บ blog โ€บ javascript-regular-expression-for-phone-number-verification
JavaScript Regular Expression for Phone Number ...
The problem is getting people to enter their phone numbers in the correct format. That being said, the solution should be one that works with multiple countries and carriers. A typical solution is to use regular expressions to make sure the value looks like a valid phone number.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ validate-phone-numbers-in-javascript-with-regular-expressions
Validate Phone Numbers in JavaScript with Regular Expressions
June 7, 2023 - We have already understood the basic structure of a phone number. We have also learned about regular expressions and how they can be used in JavaScript. In this section, we will write a simple JavaScript function that validates phone numbers of the given format: COUNTRY_CODE-AREA_CODE-TELEPHONE_PREFIX-LINE_NUMBER
๐ŸŒ
RegExr
regexr.com โ€บ 3gjfl
Get phone country code
Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns.
๐ŸŒ
regex101
regex101.com โ€บ library โ€บ wZ4uU6
regex101: Regex for telephone numbers all over the world
This regular expression is designed to validate Egyptian mobile phone numbers by ensuring they conform to the following format: Country Code: The number must start with +20, representing Egypt's international dialing code.
Find elsewhere
๐ŸŒ
Kevinleary
kevinleary.net โ€บ blog โ€บ validating-real-phone-numbers-javascript
Kevinleary.net: JavaScript Phone Number Validation: Regex & libphonenumber-js
December 8, 2024 - Validate phone numbers in JavaScript using regular expressions and the libphonenumber-js library. This guide covers simple regex, NANP validation, and international numbers.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-validate-phone-numbers-using-javascript
How to Validate Phone Numbers Using JavaScript - GeeksforGeeks
July 23, 2025 - For this, the following code can be used: ... function isValidPhoneNumber(phone) { const regex = /^\d{10}$/; return regex.test(phone); } // Example usage: console.log(isValidPhoneNumber("1234567890")); // true console.log(isValidPhoneNumber...
๐ŸŒ
Medium
developerking.medium.com โ€บ how-to-integrate-international-phone-number-validation-in-input-field-with-javascript-55d8e4b432c4
How to integrate international phone number validation in input Field with javascript ? | by Developerking | Medium
January 16, 2023 - For example, you could use the following regular expression to check for a valid international phone number: ... This regular expression allows for an optional "+" sign followed by the country code, and then the phone number.
๐ŸŒ
ServiceNow Community
servicenow.com โ€บ community โ€บ itsm-forum โ€บ required-regex-for-mobile-number-validation โ€บ td-p โ€บ 651990
Required Regex for mobile number validation - ServiceNow Community
January 2, 2026 - Hi Team, i need regex for validating mobile number. Its simple that we need to validate 1 variable when user gives his mobile number it should start with country code (example : +91,+46). If not it should show an alert that your number is not valid as its missing with country code.
๐ŸŒ
Trestle
trestleiq.com โ€บ home โ€บ product โ€บ phone validation regex: the what, how, and pros and cons
Phone Validation Regex: The What, How, and Pros and Cons
September 24, 2025 - Regex is flexible, and you can ... at the below phone regex pattern: ... This regex pattern would allow a phone number field to be populated with any 9-digit phone number from any country code 1-3 digits long....
๐ŸŒ
Qodex
qodex.ai โ€บ home โ€บ all tools โ€บ getting started โ€บ phone number regex javascript validator
Phone Number Regex JavaScript Validator โ€” Test Patterns
Validate phone number formats using JavaScript regex. Test international, U.S., and local patterns with real-time matching. Free, no signup.
Rating: 4.9 โ€‹ - โ€‹ 60 votes
๐ŸŒ
O'Reilly
oreilly.com โ€บ library โ€บ view โ€บ regular-expressions-cookbook โ€บ 9781449327453 โ€บ ch04s03.html
4.3. Validate International Phone Numbers - Regular Expressions Cookbook, 2nd Edition [Book]
August 27, 2012 - 4.3. Validate International Phone NumbersProblemYou want to validate international phone numbers. The numbers should start with a plus sign, followed by the country code and... - Selection from Regular Expressions Cookbook, 2nd Edition [Book]
Authors ย  Jan GoyvaertsSteven Levithan
Published ย  2012
Pages ย  609