Trimming a string using spaces as a delimitter
I'm trying to retreive email addresses from individual message bodies. I'm using the following code and it is working well :
<cfset addrpos = ListContainsNoCase(getmail.body, "@", " <> ")>
<cfif addrpos neq 0>
<cfset email = ListGetAt(getmail.body, addrpos, " <> ")></cfif>
For the most part this is working well, but at times the <> characters are not surrounding the email address in the message bodyand I'm ending up with the email address and a combination of the word before, word after or both. Is there a better way to handle this situation? I tried the following which works when I set the email variable in the example, but does not work when I use the same code in the loop that is getting the original email variable.
<cfset email = "adfga: chunt@example.com adfw asdfa">
<cfset addrpos1 = ListContainsNoCase(email, "@", " ")>
<cfset EMAIL = ListGetAt(email, addrpos1, " ")>
I looked at the GetToken function but did not think that it would be a better way to go at it. Any other ideas?