Hi all,
Guess I have to answer this myself...
If the text in the emails had been consistent, AS could have done the
job, but it's not stable enough.
Grep to the rescue.
set grepPattern to "[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]"
In order to get the stdout from the CLI, it seems we have to use
'echo',
and then pipe the variable data to grep:
set theDates to (do shell script "echo " & quoted form of theBody & " |
grep -e '" & grepPattern & "'") as text
Consider the mailbody below, it will give us back a two-line reply:
-> "02-10-2004 00:00
02-10-2004 06:00"
For some reason, we can't do:
set myDate to "02-10-2004 00:00" as date
But, this seems to work:
set dd to "02-10-2004 00:00"
set myDate to (date dd)
Now, if only the CLI grep was as flexible as the one in BBEdit... :-/
____________________________________________
Jakob Peterhänsel
Network Consultant
Tel: +45 7022 1014
Fax: +45 7022 1013
Mob: +45 22 68 49 61
email@hidden
www.NetPoint.com
On 25. okt 2004, at 15:11, Jakob Peterhänsel wrote:
Hi All, I have some messages coming in via Mail.app that I woudl like
to process, parse and create entries in iCal for.
As they are not that structured, I would like to ask how the gurus on
this list would handle this: Native in AppleScript, or via grep/do
shell script?
The messages body looks something like this:
----------------------------------------------------------------------
-----------------------------------
For at sikre stabil liniedrift, foretager vi med kort varsel en
kritisk opgradering i følgende område:
Hele landet
Der vil blive foretaget en kritisk software opgradering i tidrummet
mellem 0:00 og 6:00
I perioden:
02-10-2004 00:00
til
02-10-2004 06:00
Følgende platforme vil blive berørt:
VPN, Medarbejderbredbånd, Data/Internet
Vi beklager de gener, dette måtte medføre.
----------------------------------------------------------------------
-----------------------------------
I would like to get the two dates, if they exists, the line with "Hele
Landet" and the line starting with "VPN, Medarbejderbredbånd...."
Any clues?
____________________________________________
Jakob Peterhänsel
Network Consultant
Tel: +45 7022 1014
Fax: +45 7022 1013
Mob: +45 22 68 49 61
email@hidden
www.NetPoint.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
e.dk
This email sent to email@hidden
<ATT1239799.txt>