On Thu, Oct 16, 2003 at 02:23:45PM +1000, Justin French wrote:
: 
: I have the following:
: 
: <?
: $quote = "&#822[0|1]{1};";
: $text = preg_replace(
:       "/$quote(.*)$quote:$quote(.*)$quote/",
:       "<a href='\\2'>\\1</a>",
:       $text
:       );
: ?>
: 
: It basically matches "link text":"url" with the added twist of having 
: the quotes converted to &#8220; or &#8220; by a previous function.
: 
: It works fine if there is one link found inside a string, but falls 
: over horribly if there's two links inside a string.
: 
: How can I improve the (.*) to exclude $quote ?

Try inverting the greediness with a "U" pattern modifier:

        "/$quote(.*)$quote:$quote(.*)$quote/U"

For more details:

        http://www.php.net/manual/en/pcre.pattern.modifiers.php

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

Reply via email to