jaymc Posted January 12, 2009 Share Posted January 12, 2009 I have this code $string = preg_replace('/(\[img\])(.*)(\[\/img\])/i','<a href="$2" target="BlaNk"><img src="$2"></a>',$string); I only want to parse the $string if $2 starts with "http://www.website.com" Any ideas? Link to comment https://forums.phpfreaks.com/topic/140579-solved-preg_replace-string-check/ Share on other sites More sharing options...
effigy Posted January 12, 2009 Share Posted January 12, 2009 Can you not incorporate that into your pattern? Link to comment https://forums.phpfreaks.com/topic/140579-solved-preg_replace-string-check/#findComment-735669 Share on other sites More sharing options...
jaymc Posted January 12, 2009 Author Share Posted January 12, 2009 Ah ok, got it! Took a bit of playing around didnt realised you had to comment out \.co\.uk Cheers! Link to comment https://forums.phpfreaks.com/topic/140579-solved-preg_replace-string-check/#findComment-735685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.