PDA

View Full Version : Converting e-mail to hypertext in Dreamweaver


gcaseley
03-04-2010, 08:59 PM
I have a document with dozens of e-mail addresses that have not been converted to hypertext - e.g., garth@caseley.net but not garth@caseley.net
(garth@caseley.net)
Is there any way Dreamweaver can do this for me, automatically? I use version 8 and CS4.

Is there any other (inexpensive or free) program that can do this?

Thanks!

DWcourse
03-04-2010, 09:55 PM
Actually you can using regular expressions in Dreamweaver's find and replace in CS4. Let me see if I can look up the code for you. I've done it before.

gcaseley
03-04-2010, 10:11 PM
Thank you!

DWcourse
03-04-2010, 10:47 PM
This is quick and dirty but should catch most email addresses. I'd definitely back up your file first and use this on a copy to make sure it works OK. And make sure there aren't any existing links in the copy.

In DW's find and replace dialog:

Find in: Current Document
Search: Source

Find: ([\w\.]*@[\w]*.\w{2,3})
this will find a string of alphanumeric characters (\w) or periods followed by an @ sign and more character followed by a period followed by 2 or 3 more characters like I said it will miss some.

Replace: <a href="mailto:$1">$1</a>
the $1 is the email address you found above

Make sure "Use regular expression" is checked.

Good luck.

gcaseley
03-04-2010, 11:42 PM
Thank you for this. I do have a few e-mail addresses in the document now, so I'll use a backup copy and remove those links first.

G

gcaseley
03-04-2010, 11:49 PM
This resulted in, for example:

<a href="mailto:amos@yahoo.com">amos@yahoo.com</a>

but did not give produce the hyperlink (blue color) as in amos@yahoo.com

I really do appreciate your assistance!

G

DWcourse
03-05-2010, 12:34 AM
That's the right code for a link. Since you're making changes in the code (you did change in the code right?), the design view will need to refresh before you see the blue link color. Just click in design view or preview in your browser.

gcaseley
03-05-2010, 12:48 AM
Oops, I made the changes in the Design view - and when I did it in the Code view, of course it works perfectly...

...except that a lot of my e-mail addresses are at the third level - such as amos@nb.sympatico.ca or amos@nbnet.nb.ca - which of course this code doesn't catch. If you have time and are so inclined and if it is possible, is there any way that a second sweep with find|replace might catch up with those?

In any case, many, many thanks. It works!

G

DWcourse
03-05-2010, 01:09 AM
try a second sweep finding this

([\w\.]*@[\w]*\w*.\w*.\w{2,3})

with the same replacement string

gcaseley
03-05-2010, 02:06 AM
That worked well - thank you very much!

G

DWcourse
03-05-2010, 03:59 AM
Find and replace with regular expressions is very powerful. Wish I knew more about it.