Skip to content

Instantly share code, notes, and snippets.

@hanigamal
Created June 11, 2012 16:04
Show Gist options
  • Save hanigamal/2910853 to your computer and use it in GitHub Desktop.
Save hanigamal/2910853 to your computer and use it in GitHub Desktop.
Regex for the whole unicode range
$string = <<<EOF
<p dir="rtl">
أَفَلاَ يَتَدَبَّرُونَ الْقُرْآنَ وَلَوْ كَانَ مِنْ عِندِ غَيْرِ اللّهِ لَوَجَدُواْ فِيهِ اخْتِلاَفًا كَثِيرًا
</p>
EOF;
preg_match('/<p dir=(?:"rtl"|\'rtl\')>([\x{0600}-\x{06FF}\x{0750}-\x{077F}\x{FB50}-\x{FDFF}\x{FE70}-\x{FEFF} \r\n]+)<\/p>/um', $string, $matches);
$match = $matches[1];
echo $match;
@arabiancoder
Copy link

السلام عليكم ورحمة الله وبركاته
التالية هي للحروف فقط
([\x{0620}-\x{063A}\x{0641}-\x{064A}])
والتالية هنا خاصة بالتشكيل
([\x{064B}-\x{0652}])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment