help need to "read from file until xxxx OR yyyy OR zzzz"
Dar Scott
dsc at swcp.com
Tue Dec 14 12:47:06 EST 2004
On Dec 14, 2004, at 7:46 AM, Randy Padawer wrote:
> The text file is made up of many individual emails concatenated
> end-to-end.
Rather than parsing on the lead line, maybe you can parse on the email
format. Something like this, only in regex?
Optional blank lines
Start of capture for single email
Some non-blank lines
Blank line
Obtional lines
End of capture
dot line
Start of capture for rest of emails
blah-blah
end of file
End of capture
If the file is long, the second capture might be slow. You might want
to consider matchChunk instead of matchText and match on either a
single char or the end. That would get you the char position of the
end. It might be possible to capture nothing.
If you want the dot line in the mail, just move the end of capture.
This might have problems with some special cases such as an empty body;
you might have to look at the syntax for that.
You can read the file in binary and do parsing on cr lf lines and then
convert to your platform, if you want.
Dar Scott
****************************************
DSC
http://www.swcp.com/dsc/
Programming Services
****************************************
More information about the use-livecode
mailing list