regexarray("•3/23/17 @1:59 PM - Doug & Kristin off to NY by way of
Utah etc for a month; gone six months? kristin_douglas@yahoo.com",
"([\w!#$%&'*+/=?`{|}~^.-]+)@([A-Z0-9.-]+\.[A-Z]{2,3})",", ")
Hold it, I see after rereading that you probably wanted the entire text after the initial section and not the email address at the end. I default to Dave’s solution.
You could use the onewhitespace( function on the text, and then do an ArrayFilter with space as the separator. The formula would test for
import() match "*?@?*.?*"
that would ensure that there was at least one non-white space character on either side of the @, and that it included a dot somewhere after the @, with no intervening spaces.
That would work in the original example data, but would not work if the email had any punctuation immediately before or after it, like a comma, period, parenthesese, etc.) This is a very difficult problem to solve without regular expressions (and even then, it may not be perfect).
Gary’s example works for me in Pan X. Dave’s example (on whidh Jim has commented), did not work.
I used:
/* Monday, December 4, 2017
Also am wondering if isolation of the (first) email in a bunch of text can be done in Pan6?
You could use the onewhitespace( function on the text, and then do an ArrayFilter with space as the separator. The formula would test for
import() match "?@?.?*"
that would ensure that there was at least one non-white space character on either side of the @, and that it included a dot somewhere after the @, with no intervening spaces.
*/
local x,lEmail
x=Comment //which contains an email address
lEmail=onewhitespace(x)
Or easier: textafter(“•3/23/17 @1:59 PM - Doug & Kristin off to NY by way of Utah etc for a month; gone six months? kristin_douglas@yahoo.com”,“-”,1) (or "= " if you do not want the initial space.)
If you want to extract the email address, you can use a text funnel to throw out all the text before the final space:
•3/23/17 @1:59 PM - Doug & Kristin off to NY by way of Utah etc for a month; gone six months? kristin_douglas@yahoo.com["- ",-1].
Or more simply, you can use lastword(“•3/23/17 @1:59 PM - Doug & Kristin off to NY by way of Utah etc for a month; gone six months? kristin_douglas@yahoo.com”)
These functions are in both 6 and X. There are an abundance of methods for doing this.
In Craig’s initial example the email address happened to be at the end of the text, but I’m pretty sure he wanted to extract the email address no matter where it was in the text, and if there are multiple email addresses, he wanted to extract all of them. So any solution that assumes a fixed location is not what Craig was looking for. Dave’s arrayfilter idea will work in Panorama 6, but only if the email address has white space around it, not any punctuation. The regular expression solution will work even if there is punctuation before or after, and will reject most invalid email addresses, for example it knows that joe@123 is not a valid email address even though it kind of looks like one. However, of course, regular expressions can only be used in Panorama X.
Here is a version of Dave’s Panorama 6 scheme on steroids. It should get the lion share of addresses including those adjacent to punctuation marks. There will obviously be special situations where it will not work like if there is only a punctuation between the address and additional text without any existing white space. Anyway, here it is:
local lEmail
lEmail=TheField //field containing text in question
//allow only characters used in email addresses plus space & return
lEmail=stripchar(lEmail,
"@@.. !!##$$%%&&''**++--//==??^^__``{{||}}~~;;09azAZ"+¶+¶)
//replace spaces with returns
lEmail=replace(lEmail," ",¶)
//extract text that match an email address & remove trailing period
arrayfilter lEmail,lEmail,¶,?(import() match
"?*@?*.?*",import()[1,"≠-."],"")
//strip extra returns
lEmail=arraystrip(lEmail,¶)
//outputs a return separated list of included email addresses
message lEmail