Hi,

I've got a problem with regular expression syntax with ereg_replace:

ereg_replace(':start:(.*):end:','this is \\1',':start: first :end: middle :start: last 
 :end:');

   returns - this is first :end: middle :start: last

   but I want - this is first middle this is last

The problem seems to be that ereg_replace is being greedy on the match and matching as 
much as it
can 
instead of just finding the first match, handling that and then going on to the next 
match.

I can get it to work with preg_replace i.e. 

preg_replace(':start:(.*?):end:','this \\1',':start first :end: middle :start: last 
:end:')

   returns - this is first middle this is last 

But my actual string is on multiple lines, and preg_replace doesn't seem to continue 
trying
to match on the next line, whereas ereg_replace happily treats newlines just like any 
other
character.

So how do I stop ereg_replace being greedy or alternatively get preg_replace to treat 
multiple 
lines as a single source string?


George

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to