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? Quote 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? Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.