CNk CNk - 4 months ago 40
PHP Question

Preg Match for Letters in Arabic and Numbers in English

I want to allow my users to enter such record - Letters in Arabic and Numbers in english. (عسا871)

And I run a preg match on the top, I tried it this way -

die("Number Data Modification");

It still does not accept Arabic, what is a right way to do it?


The ^[0-9]|[\p{Arabic}]+$ regex accepts strings that have 1 ASCII digit at the start of string (^[0-9]) or (|) Arabic letters at the end ([\p{Arabic}]+).

Most probably you want to allow any string consisting of either ASCII digits or Arabic letters:


See the regex demo