Is there a bug in Satimage.osax or am I just not understanding something? I have this AppleScript:
â
set regex_flags to {"MULTILINE"}
set theContact to grep("^Client Name:\\s+(.*)\\n", theContent, "\\1", {})
set theContactEmail to grep("^Email:\\s+(.*)\\n", theContent, "\\1", {})
set thePackage to grep("has booked\\s+(.*)\\s+with", theContent, "\\1", {})
set theAddress to grep("at\\s+(.*)\\s+on", theContent, "\\1", {})
set theUser to grep("with\\s+(.*)\\s+at", theContent, "\\1", {})
set theTime to grep("on\\s+(.*)\\.\\s+$", theContent, "\\1", {})
set theNote to grep("^Email:\\s+(.*)\\n(.*)", theContent, "\\2", regex_flags)
on grep(findThis, inThis, returnThis, regex_flags)
try
return find text findThis in inThis using returnThis regexpflag regex_flags with regexp and string result
on error errMessage number errNumber
if errNumber is equal to -2763 then
return ""
end if
end try
end grep
This works fine except for theNote. I’m parsing an email message with content similar to this
John Smith has booked Photo Package 1 with Jane at 123 Main St, Los Angeles 90001 on 09.12.13 3:00 PM.
Client Name: John Smith
Email: john@example.com
Lockbox Code: tenant Elmo will be there
Status: rental
Contacts Name: Sam
Contacts Number: 555-999-0000
Notes: Thank you:)
theNote is set to “Lockbox Code: tenant Elmo will be there” if I don’t use {“MULTILINE”}; when I do use that, however, theNote is “”. How do I get all the text following the Email line?