Page 1 of 1

ereg_replace - too smart

Posted: Mon Sep 27, 2004 3:39 pm
by Ne0
im using ereg_replace to highlight anything in qoutation marks ("), and it works fine, except, it will look for the first quotation mark, and then the last one, sometimes there may be more then one thing in quotes, like this:
hi "how are you" and "talk to you later"
would start at the first quote before how and end at later.
im using

Code: Select all

$tlf = ""(.*)"";
thats what the ereg_replace looks for. Is there a way to stop this? so that it would highlight "how are you" by itselfm, then "talk to you later"?

thanks in advanced.

Posted: Mon Sep 27, 2004 3:45 pm
by feyd

Code: Select all

preg_replace('#"(.*?)"#',........)

Posted: Mon Sep 27, 2004 3:56 pm
by Ne0
ah, thank you.
but what exactly did that do? why did the # and preg_replace fix it?