Tom
Tom

Reputation: 9653

Regex to match mixed Arabic and numbers

return preg_match('/^(\d*\p{Arabic}+*)$/iu', $str);

I'm using the function above in order to match string such as: - "somewordinArabic" - "3somewordinArabic" etc

But i want it to match also cases like: - "3somewordin444Arabic" - "somethingarabic22"

So basically mixed arabic with numbers, with the exepcetion that at least one letter is in arabic,

Can someone help me?

Upvotes: 4

Views: 1333

Answers (1)

zellio
zellio

Reputation: 32504

/^[\d\p{Arabic}]*\p{Arabic}[\d\p{Arabic}]*$/ui

Upvotes: 3

Related Questions