php - preg_match a hyperlink -
i looked everywhere answer, seems cannot head around preg_match functionality. want preg_match link below numbers part (the id) dynamic.
link:
http://video.cnbc.com/gallery/?video=3000024508 here goes have come until now:
preg_match( '/^http://video.cnbc.com/gallery/?video=([0-9_-]/', $content ) but won't work.
preg_match('#^http://video\.cnbc\.com/gallery/\?video=([0-9_-]+)$#', $content); besides problems others mentioned (escaping ? , . , using # instead of /) missing + after number group ([0-9_-]), means group can repeated.
if need check if string includes kind of link or not, remove ^ , $:
preg_match('#http://video\.cnbc\.com/gallery/\?video=([0-9_-]+)#', $content);
Comments
Post a Comment