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>&nbsp;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>&nbsp;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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -