Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  78] [ 1]  / answers: 1 / hits: 27959  / 11 Years ago, wed, june 26, 2013, 12:00:00

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);
}

More From » regex

 Answers
26

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-u06FFs]+$/;

if (!p.test(str)) {
alert(not format);
}
}


Adapted to JavaScript from this question: Regex for check the input string is just in persian language


[#77405] Tuesday, June 25, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatianah

Total Points: 185
Total Questions: 99
Total Answers: 87

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;