Re: >>Remove Dynamic String between StringA and StringB

From: Date: Tue, 27 Jan 2004 12:44:24 +0000
Subject: Re: >>Remove Dynamic String between StringA and StringB
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175896@lists.php.net to get a copy of this message
$pattern = "/$stringA.*?$stringB/"; .*? -> matches everything between $stringA and $stringB
      the "?" means: stop matching after the first occurence
      of $stringB (quantifier minimizer). otherwise ".*" would
      match everything between the first occurence of $stringA
      and the last occurence of $stringB
-> http://ch2.php.net/manual/de/pcre.pattern.syntax.php g. tinu Tue, 27 Jan 2004 13:25:27 +0100 Jack Bauer <jackbauer@elict.org>:
Hi :), i tried your code zu replace some parts of a string, the problem is that this method only replaces when there is only 1 word between stringA and stringB. i got the problem that the part between both strings is a dynamic one and much larger then 1 word. i really tried to use the php manual and google to find some help for this, but i got no luck with that :( $stringA = "AA"; $stringB = "BB"; $string = "AA oneword BB AA two words BB"; $pattern = "/$stringA.\w*.$stringB/"; $replacement = ""; echo preg_replace($pattern, $replacement, $string); i think it have to do something with the \w in the pattern, is there a parameter to resolve my problem too? regards manuel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#175896) next »