> The following line sort of works: > $retVal = > preg_replace("/(.*){parent.(.*)}(.*)/e","'\\1'.\$this->parentNode- > >getProper tyValue('\\2').'\\3'",$retVal); > > However, if there are more than one string to replace it only works > on the last one. So: > caption = "the parent's coordinates are ({parent.left}, > {parent.top})" would only return something like: "the parent's > coordinates are ({parent.left}, 100)"
That is because the first (.*) skips the first parent.x pattern. It seems the string is parsed backwards. To avoid this problem, be more specific in your regexp. Don't use (.*), but ([^{]*) instead. The regexp which works in your example is the following: /([^{]*){parent.([^{]*)}([^{]*)/e HTH Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php