----- Original Message ----- 
From: "Gordon Stewart"

Hi,

I've got the script below - However it does not work...

can you advise the error I have.. please - Explanation below....


==============
$test=implode("",$FILES);

echo "FILES\n$test\n";

if (preg_match("/.*\n\s*word1:\s*(.*?)\n\s*(word2:\s*.*?)\n\s*\n(.*)$/ims",
$test,$matches)){
 echo "FOUND $matches[1]\n";
 echo "FOUND 2 $matches[2]\n
";
==============

Basically,

$FILES, is the entire text of an inward email (headers & all..)

I looked on the web - Google - & found I need to 'implode' - To search
multi-lines...

(I tried to preg_match directly on $FILES - Still didnt work...)

Basically, I am looking for

(Blank line)
word1: (text here)\n
word2: (text here)\n
word2: (text here)\n
word2: (text here)\n
word2: (text here)\n
(blank line)


I'm looking for the phrase "word1", a semi colon, then ANY text before
the next \n

then the next line has "word2" a semicolon, then any text - And a new-line..

** There can be multiple instances of WORD2

and it stops on the next blank line - & saves it to $matches[1] & 
$matches[2]


Is the /ims correct - At the end (I want "i" - Case insensitive...)

Can anyone help - Thank you....
------------------------------

$FILES = str_replace('\r\n', '\r', $FILES);
$FILES = str_replace('\r', '\n', $FILES);
while(strpos($files, '\n\n' !== FALSE)
  {
  $FILES = str_replace('\n\n', '\n', $FILES);
  }
$files = explode('\n', $files);
foreach($files as $oneline)
  {
  if((tolower(substr($oneline, 0, 4)) == 'word') && substr($online, 5, 2) == 
': ')
    {
    $word[substr($oneline, 4, 1)][] = strip(substr($oneline, 7));
    }
  }
foreach($word[1] as $text)
  {
  echo('Word1 = ' . $text . "<br>\n");
  }
foreach($word[2] as $text)
  {
  echo('Word2 = ' . $text . "<br>\n");
  }

e-mail protocol -
header\r\n\r\n
line1\r\n
line2\r\n
line3\r\n
\r\n
.
\r\n


Reply via email to