Justin French wrote:
this is supposed to any occurrence of *something* into <strong>something</strong>

$str = preg_replace("!\*(.*?)\*!"," <strong>\\1</strong>\\2",$str);

it works fine on single lines, but it breaks when there's a \n (and perhaps other white spaces?) in the string, eg:

*something with
a newline*


I think this is because .*? doesn't include newlines... can anyopne help me modify the above to work on multiple lines????

Yes, that's the reason. Use an 's' modifier to make the dot character match newlines. It's all in the F manual. :)


$str = preg_replace("!\*(.*?)\*!s"," <strong>\\1</strong>\\2",$str);

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to