Reputation: 17964
I have HTML form input to be validated. The input should only use Unicode (Persian) letters and numeric nothing else. I used the preg_match
like this:
preg_match('/^[آإأابپتثجچحخدذرزژسشصضطظعغفقکگلمنهۀةوؤیيئءًٌٍَُِّ\s]+$/u',$input);
and it works fine on localhost, but as my hosting does not have PCRE with Unicode support installed and I am not going to ask them to install it for me, I am looking for another working way to accomplish this.
Are there any ways in which I can validate unicode input, without using preg_match()
function?
Accrding to the duplicate flag, I am not after a PCRE, 'preg_match' way. The linked question is a PCRE 'preg_match' way.
Upvotes: 0
Views: 785
Reputation: 48751
There are some specific multi-byte functions that you may benefit from when PCRE is not compiled with PCRE_UTF8
flag:
mb_regex_encoding('UTF-8');
var_dump(mb_ereg('^[آ-یء\s]+$', "سلام پارسی تست می کنیم آإأابپتثجچحخدذرزژسشصضطظعغفقکگلمنهۀةوؤیيئًٌٍَُِّ"));
// int(1)
Here آ-ی
character range includes more characters than Persian has (actually U+0622
- U+06CC
, look at corresponding Unicode table) also note that no delimiters are specified.
Upvotes: 1