Posted By

adampatterson on 02/08/11


Tagged

regex url php html


Versions (?)

Regular Expression for URLs using ereg_replace


 / Published in: PHP
 

URL: http://www.adampatterson.ca/blog/2011/02/regular-expression-for-url-using-ereg_replace/

  1. // $subject contains a body of text with non html URLs
  2. $text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=\"\\0\">\\0</a>", $subject);

Report this snippet  

You need to login to post a comment.