How can I define a regular expression which solely accept Persian alphabet characters?
I tried the following function, but it doesn't work properly:
function Just_persian(str){ var p=/[پچجحخهعغفقثصضشسیبلاتنمکگوئدذرزطظژؤإأءًٌٍَُِّ\s]+$/; if(!str.match(p)) alert("invalid format"); }
Persian characters are within the Arabic Unicode block, which ranges from U+0600 to U+06FF (which is specified in character class as \u0600-\u06FF
).
function just_persian(str){ var p = /^[\u0600-\u06FF\s]+$/; if (!p.test(str)) { alert("not format"); } }
Adapted to JavaScript from this question: Regex for check the input string is just in persian language
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With