Pakistan Special
JazzCash or Easypaisa Wallet Number Regex
JazzCash and Easypaisa wallets are identified by the owner's mobile number, so payment instructions in invoices, chats and online shops often read like JazzCash: 0300-0000000. This pattern searches for either label in any letter case, with or without a space inside the name, then allows up to fifteen non-digit characters such as a colon or the word number, and captures the mobile number in group 1. Requiring the label means a phone number in a signature is not mistaken for a payment account. A regex cannot tell whether a number is registered with a wallet service, so confirm details before sending money.
Pattern (JavaScript)
/\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b/iMatches a word boundary, then (the text "jazz", then a whitespace character (space, tab, newline), optionally (zero or one time), then the text "cash" OR the text "easy", then a whitespace character (space, tab, newline), optionally (zero or one time), then the text "paisa"), then a word boundary, then any character that is not a digit, between 0 and 15 times, then a group (the text "03", then exactly 2 digits, then the character "-", optionally (zero or one time), then exactly 7 digits), then a word boundary.
Limit: A regex cannot tell whether a number is registered with a wallet service.
Examples
Matches
- ✓ JazzCash: 0300-0000000
- ✓ Send to Easypaisa 03001234567
- ✓ easy paisa number 0345-1234567
Does not match
- ✗ 0300-0000000
- ✗ JazzCash: 12345
- ✗ Bank: 0300-0000000
Try it
3 matches (JavaScript engine)
JazzCash: 0300-0000000 Send to Easypaisa 03001234567 easy paisa number 0345-1234567 0300-0000000 JazzCash: 12345 Bank: 0300-0000000
Code in 8 languages
Converted automatically from the JavaScript pattern; language-specific notes are shown where the syntax or support differs.
JavaScript
const re = /\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b/gi;
const text = "JazzCash: 0300-0000000";
const matches = [...text.matchAll(re)].map((m) => m[0]);
console.log(matches);Python
import re
pattern = re.compile(r'\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b', re.I)
text = 'JazzCash: 0300-0000000'
matches = [m.group(0) for m in pattern.finditer(text)]
print(matches)PHP
<?php
$pattern = '/\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b/i';
$text = 'JazzCash: 0300-0000000';
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("\\b(?:jazz\\s?cash|easy\\s?paisa)\\b\\D{0,15}(03\\d{2}-?\\d{7})\\b", Pattern.CASE_INSENSITIVE);
String text = "JazzCash: 0300-0000000";
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}Go
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`(?i)\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b`)
text := "JazzCash: 0300-0000000"
fmt.Println(re.FindAllString(text, -1))
}C#
using System;
using System.Text.RegularExpressions;
var pattern = new Regex(@"\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b", RegexOptions.IgnoreCase);
var text = "JazzCash: 0300-0000000";
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"(?i)\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b").unwrap();
let text = "JazzCash: 0300-0000000";
for m in re.find_iter(text) {
println!("{}", m.as_str());
}
}- Add regex = "1" under [dependencies] in Cargo.toml.
Ruby
pattern = /\b(?:jazz\s?cash|easy\s?paisa)\b\D{0,15}(03\d{2}-?\d{7})\b/i
text = 'JazzCash: 0300-0000000'
matches = text.to_enum(:scan, pattern).map { Regexp.last_match[0] }
p matchesFrequently asked questions
- Why not just use the mobile number pattern?
- Every wallet number is also a mobile number, so the mobile pattern cannot tell them apart. Requiring the JazzCash or Easypaisa label finds numbers that were given as payment accounts.
- Can this confirm the number has an active wallet?
- No. A regex cannot tell whether a number is registered with a wallet service. Only the wallet provider can confirm that, usually by showing the account title before payment.
- Why allow up to fifteen characters between the label and the number?
- People write things like "JazzCash account:" or "Easypaisa no." before the number. The limit is generous enough for those but stops the pattern from linking a label to a number far away in the text.