LPM: RE: Regexps for email.
ken.rietz at asbury.edu
ken.rietz at asbury.edu
Wed Jan 26 13:42:24 CST 2000
> I'm working on a script which goes through a link library I have and
> throws down mad links. I'm having a problem with my email nonsense.
>
> ideally, I'd like this bit of the program to take something like:
> --
> here is an email address:booberry at io.com
> --
> and turn it into:
> --
> here is an email address:<a
> href="mailto:booberry at io.com">booberry at io.com</a>
> --
>
> I am using the following rexexp:
> $inline =~ s/\b(\w+\@\w+(\.\w+)*\.\w+)\b/<a
> href=\"mailto:$1\">$1<\/a>/g;
>
> The problem is, it continues matching on the line. Hence, I get three
> nested requests. Cool, but not useful. How can I tell the
> regexp engine
> not to attempt a match on the text that it just inserted?
>
I'm with Dave -- not a regex expert and confused about why you are
having a problem. The regex you give works for me. Well, almost.
My e-mail is ken.rietz at asbury.edu, which fails to find the full
username. I'd recommend changing the substitution to
$inline =~ s/\b([\w.]+\@\w+(\.\w+)*\.\w+)\b/<a
href=\"mailto:$1\">$1<\/a>/g;
(added three characters), so that addresses like mine could be
formatted correctly.
-- Ken Rietz
More information about the Lexington-pm
mailing list