Script for tagging email addresses

Jim Ault jimaultwins at yahoo.com
Sat Mar 27 01:57:30 EDT 2010


First, I think you have a typo...
>
>
> E-mail: <a  
> href="Mailto:wonderboy at orcon.net.nz"wonderboy at orcon.net.nz</a>¬
is missing the closing '>'
E-mail: <a  
href="Mailto:wonderboy at orcon.net.nz">wonderboy at orcon.net.nz</a>¬

secondly, the href string does not have to be enclosed in quotes, so
E-mail: <a href=Mailto:wonderboy at orcon.net.nz>wonderboy at orcon.net.nz</ 
a>¬
would work.


------- start code   --------
-- assumes a masterList variable set to all lines
--  1000 email addresses takes about 6 seconds on an older Mac

    put masterList into emailLinesOnly
    filter emailLinesOnly with "*@*"
    set the itemDel to ":"

    repeat for each line LNN in emailLinesOnly
       put word 1 to -1 of item 2 of LNN & tab & 0  & cr after newLines
       --  the 0 is a placeholder
    end repeat
    filter newLines without empty
    split newLines using cr and tab
    --dups have now been removed
    --sequence does not matter
    put the keys of newLines into emailAddrList
    filter emailAddrList without empty
    set the itemdel to tab
    repeat for each line LNN in emailAddrList
       replace LNN with ("<a href=" & LNN & ">" & LNN & "</a>") in  
masterList
       --handles duplicate email addresses in one replace step
    end repeat

    put  masterList into msg

------- end code   --------

Jim Ault
Las Vegas

On Mar 26, 2010, at 8:40 PM, Sivakatirswami wrote:

> anyone have an efficient script for tagging email address with links?
>
> let's say I have a chunk of plain text made up of one or more of  
> these:
>
> And we want to replace them with links
>
>
> Mr. Wonder Boy
> 108 Webster Avenue
> 1004  Mount Zena,
> NEW ZEALAND
> E-mail:  wonderboy at orcon.net.nz ¬
>
> Mr. Wonder Boy
> 108 Webster Avenue
> 1004  Mount Zena,
> NEW ZEALAND
> E-mail:  wonderboy at orcon.net.nz ¬
>
> becomes:
>
> Mr. Wonder Boy
> 108 Webster Avenue
> 1004  Mount Zena,
> NEW ZEALAND
> E-mail: <a  
> href="Mailto:wonderboy at orcon.net.nz"wonderboy at orcon.net.nz</a>¬
>
> Mr. Wonder Boy
> 108 Webster Avenue
> 1004  Mount Zena,
> NEW ZEALAND
> E-mail: <a  
> href="Mailto:wonderboy at orcon.net.nz"wonderboy at orcon.net.nz</a>¬
>
> I was hoping to avoid replacetext and regEx as it will make it slow.
>
> anyone have this already wired up?
>
> thanks!
>
> Sivakatirswami
>








More information about the use-livecode mailing list