As described in http://www.php.net/manual/en/function.preg-match-all.php, I
have put in place a bit of code theoretically designed to parse out snippets
of text embraced with an open and close tag.  The code I am using is this:

preg_match_all('/begincommand(.*)endcommand/',$messagebody,$commandOuttake,P
REG_PATTERN_ORDER);
print $commandOuttake[0][0]." (0,0), ".$commandOuttake[0][1]." (0,1)\n";
print $commandOuttake[1][0]." (1,0), ".$commandOuttake[1][1]." (1,1)\n";

For this input

random words begincommand another test string 1[endcommand] a couple of
random words [begincommand]2nd instance of command in same email test string
[endcommand] and then a bunch of nonsense

this code produces this output:

begincommand another test string 1[endcommand] a\r\ncouple of random words
[begincommand]2nd instance of command in same email\r\ntest string
[endcommand (0,0), (0,1) another test string 1[endcommand] a\r\ncouple of
random words [begincommand]2nd instance of command in same email\r\ntest
string [ (1,0), (1,1)


In other words, the fact that I have the begincommand ... endcommand TWICE,
the preg_match_all only accepts the OUTER open and close tags.  It never
stops at the first endcommand as I am trying to make it do.  The string "
a\r\ncouple of random words" should never show up!

I've tried this with and without the PREG_PATTERN_ORDER, with ereg,
preg_match and various and sundry other variations, and I am at a loss.  How
do I change the criteria to stop at the first instance of a match?  How do I
parse out only up to the first instance of "endcommand"?


I am not certain if I am subscribed directly to this list, so in answering,
would you be so kind as to cc: [EMAIL PROTECTED]

Thanks!
_________________________
Vania Smrkovski
Internet Design and Programming
[EMAIL PROTECTED]
http://pandorasdream.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to