#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    75
    Rep Power
    5

    Preg_replace pattern help


    I have a string like this
    Code:
      http://www.aalamy.com/p-1<br /> 	http://www.aalamy.com/p-15 	http://www.aalamy.com/p-w  	<p>http://www.aalamy.com/search-DVD</p>

    I want to put all links in <a > tags


    that all I can do after long hours,
    Code:
    $source = preg_replace( "{http://.*?[<| |\n]}", "<a href=\\1>", $source);
    can anyone help, please ?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,998
    Rep Power
    9397
    Moved from PHP.

    Try with this:
    Code:
    #http://[^<\s]+#
    (Tip: you have to do a bit more beyond copy/pasting this into your code)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    75
    Rep Power
    5
    Thanks,
    Last edited by Eng_A_Moktar; July 6th, 2010 at 08:37 PM.

IMN logo majestic logo threadwatch logo seochat tools logo