How would I get an ereg search to look for either THIS or THAT?
For example here I'm trying to get the replacement to work if an optional blank space but not a quote exists before the http://
Code: Select all
<?php
$text = "xxxxhttp://www.somewhere.com http://www.somewhere.co.uk <a href="http://www.somewhere.net">link</a>";
$searchFor = "([\\s]?[^"])http://([^\\s]+)";
$replaceWith = "\\1<a href="http://\\2">\\2</a>";
$text = eregi_replace($searchFor, $replaceWith, $text);
?>xxxx<a href="http://www.somewhere.com">http://www.somewhere.com</a> <a href="http://www.somewhere.co.uk">http://www.somewhere.co.uk</a> <a href="http://www.somewhere.net">link</a>
Cheers.