Pakistan Special
Pakistan Mobile Number (+92) Regex
In international format, a Pakistani mobile number drops the leading zero and adds the country code 92, so 0300-0000000 becomes +923000000000. Some people dial the 00 international prefix instead of the plus sign, giving 00923000000000. This pattern accepts either prefix, then requires the digit 3 and exactly nine more digits, with no spaces or dashes. That compact layout matches the E.164 style used by SMS gateways and messaging APIs, which makes it a good check right before you store a number or send it to such a service. Use the spaced pattern if your users type groups.
Pattern (JavaScript)
/^(?:\+92|0092)3\d{9}$/Starts at the start of the line/string, then (the text "+92" OR the text "0092"), then the character "3", then exactly 9 digits, then the end of the line/string.
Examples
Matches
- ✓ +923000000000
- ✓ 00923001234567
- ✓ +923451234567
Does not match
- ✗ 03000000000
- ✗ +92300000000
- ✗ +9230000000000
Try it
0 matches (JavaScript engine)
+923000000000
00923001234567
+923451234567
03000000000
+92300000000
+9230000000000Code in 8 languages
Converted automatically from the JavaScript pattern; language-specific notes are shown where the syntax or support differs.
JavaScript
const re = /^(?:\+92|0092)3\d{9}$/g;
const text = "+923000000000";
const matches = [...text.matchAll(re)].map((m) => m[0]);
console.log(matches);Python
import re
pattern = re.compile(r'^(?:\+92|0092)3\d{9}$')
text = '+923000000000'
matches = [m.group(0) for m in pattern.finditer(text)]
print(matches)PHP
<?php
$pattern = '/^(?:\+92|0092)3\d{9}$/';
$text = '+923000000000';
preg_match_all($pattern, $text, $matches);
print_r($matches[0]);Java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("^(?:\\+92|0092)3\\d{9}$");
String text = "+923000000000";
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}Go
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^(?:\+92|0092)3\d{9}$`)
text := "+923000000000"
fmt.Println(re.FindAllString(text, -1))
}C#
using System;
using System.Text.RegularExpressions;
var pattern = new Regex(@"^(?:\+92|0092)3\d{9}$");
var text = "+923000000000";
foreach (Match m in pattern.Matches(text))
{
Console.WriteLine(m.Value);
}Rust
// Cargo.toml: regex = "1"
use regex::Regex;
fn main() {
let re = Regex::new(r"^(?:\+92|0092)3\d{9}$").unwrap();
let text = "+923000000000";
for m in re.find_iter(text) {
println!("{}", m.as_str());
}
}- Add regex = "1" under [dependencies] in Cargo.toml.
Ruby
pattern = /^(?:\+92|0092)3\d{9}$/
text = '+923000000000'
matches = text.to_enum(:scan, pattern).map { Regexp.last_match[0] }
p matchesFrequently asked questions
- Why is the leading zero removed after +92?
- The zero is a trunk prefix used only for calls inside Pakistan. International numbers replace it with the country code.
- Does this accept spaces like +92 300 0000000?
- No. It expects the compact form. Remove spaces first, or use the mobile-with-spaces pattern for grouped input.
- What is E.164?
- E.164 is the international numbering plan that writes numbers as a plus sign, country code and subscriber number with no spaces. Most SMS and calling APIs expect numbers in that form.