Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dedicated Regular Expression for Persian alphabet [duplicate]

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"); } 
like image 786
Angel Avatar asked Jun 26 '13 09:06

Angel


1 Answers

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

like image 123
User 1531343 Avatar answered Sep 26 '22 19:09

User 1531343