php - preg_math getting url within the text -
i have test in users having taggings need url href text have text
hello world <a class="red" contenteditable="false" href="http://domainname.com/demo/forums/profile/test.name">test </a> this creating problem //i need test.name url $text = $post_data->discussion; $name = preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $text, $match); print_r($name);
can me out unable failed in making regex
you can check anchor tag, way you'll url (maybe string contains separate urls).
$str = 'hello world <a class="red" contenteditable="false" href="http://domainname.com/demo/forums/profile/test.name">test </a> this creating problem'; preg_match_all("/<a.*?href\s*=\s*['\"](.*?)['\"]/", $str, $res, preg_set_order); foreach($res $key => $val) { echo $val[1]; } // http://domainname.com/demo/forums/profile/test.name
Comments
Post a Comment