Always enable it with Arabic so characters are handled as full Unicode.
The letter range
[\u0600-\u06FF] covers Arabic letters, diacritics and Arabic-Indic digits.
\w is not enough
In JavaScript \w does not match Arabic letters; use the range instead.
Example: validating a mobile number in a form
Pick the Saudi mobile preset to see a pattern accepting 05XXXXXXXX and +9665XXXXXXXX. Copy it into an HTML input pattern or your PHP validation, and test right and wrong numbers here before publishing.
Key terms
Short definitions of what you meet along the way.
Regex
A compact language for describing text patterns, to search, validate and replace.
Capturing group
A part in () saved for use after matching.
Flags
Letters that change behaviour: g for all, i ignore case, u for Unicode.
We use necessary cookies to run the site, and Google Analytics to measure visits only if you agree. You can change your choice at any time from “Cookie settings”. Privacy policy