Ditto
Ditto copied to clipboard
How can I extract email addresses from a text when pasting
The text is copied from Outlook with texts like below.
Vinas, abby <[email protected]>; Vinas, tom <[email protected]>; West, Edmond <[email protected]>;
now I want to get the email addresses from this text only when pasting, how can I do it?
Did you ever figure this out?
this can be done with an on paste script. options - general - advanced - on paste scripts
`var oldString = clip.GetAsciiString(); var allEmail = ""; var email = ""; var inEmail = false; for(var i = 0; i < oldString.size(); ++i) { if(oldString[i] == '>') { if(allEmail != "") { allEmail += "\r\n" } allEmail += email inEmail = false; email = ""; } if(inEmail == true) { email += oldString[i]; } if(oldString[i] == '<') { inEmail = true; } } clip.SetAsciiString(allEmail); return
This will only work if email address is inside a <
and >
. I have use cases where you might have other formats. My hope was to match on email regex and extract that way. It does not appear that Ditto and/or ChaiScript lets you do that? I can't make sense of the ChaiScript documentation.
@sabrogden Any thoughts on how I can extract email addresses when they aren't surrounded by < or >?
My thought was to, somehow, use non email valid characters as a way to chunk up an input string. Thoughts?