ereg_replace - too smart

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ne0
Forum Commoner
Posts: 60
Joined: Sat Feb 14, 2004 11:48 am

ereg_replace - too smart

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

preg_replace('#"(.*?)"#',........)
Ne0
Forum Commoner
Posts: 60
Joined: Sat Feb 14, 2004 11:48 am

Post by Ne0 »

ah, thank you.
but what exactly did that do? why did the # and preg_replace fix it?
Post Reply