php - Preg matching Arabic? -
i'm attempting preg match link of half in english, half in arabic.
the link example looks like:
"/<arabic>/123/<arabic>-<english>.html"
the basic preg_match('@<a href="/(.*?).html" >);
returns arabic within url means no longer identifiable page, returning "دانلود-رایÚ"
example.
i've attempted things i've seen such \p{arabic}
returns nothing. there way able capture these links?
it's i'm pretty stumped , can't figure out way around issue.
edit add preg match & i'm attempting match.
preg_match_all('@<a href="/\p{arabic}/(.*?)/\p{arabic}-(.*?)" >@iu',$page,$link);
example text -
"a href="/دانلود-رایگان-کتاب/کتاب-های-خارجی/مطلب/2120-the-essential-financial.html"
think twice before using regex parse html.
$doc = new domdocument(); $doc->loadhtml($yourhtml); $links = $doc->getelementsbytagname('a'); foreach($links $link){ echo $link->getattribute('href'); }
Comments
Post a Comment