Janwillem Borleffs wrote:
brendan wrote:
trying to clear out all text between the outermost
Do you really mean 'between'?
<---Message Start--->
and
<---Message End--->
tags
[ ... ]
Simply apply the U(ngreedy) pattern modifier and simplify the pattern:
$str = preg_replace("/<---Message(.+)--->/Uis", "", $str);
That's the right idea, but a step too far. Remember that
PCRE_UNGREEDY inverts greediness; the plus sign in your
pattern isn't greedy, so the dot stops matching at the first
'--->'. All '<---Message Start--->' and '<---Message End--
->' tags are removed.
You want it to stop after the last '--->' of the final '<---
Message End--->'. The quantifier should be greedy; e.g.,
`<---Message Start--->.*<---Message End--->`s
HAGW JW!
--
Jock