Regex stumper?
Kari Chisholm
karic at lclark.edu
Thu Jul 27 13:28:24 CDT 2000
Alright, this may be a moron question, but I can't figure it out. I'm
trying to take a long string of text like this:
Email me at karic at lclark.edu, or at wwwadmin at lclark.edu, dude.
And, make it output this:
Email me at <a href=mailto:karic at lclark.edu>karic at lclark.edu</a>, or
at <a href=mailto:wwwadmin at lclark.edu>wwwadmin at lclark.edu<a/>, dude.
My code-snippet is this:
$text = "Email me at karic\@lclark.edu, or at wwwadmin\@lclark.edu,
dude.";
while ($text =~ /\s([\w\-]+\@[\w\-]+\.[\w\-]+)\B/)
{
$link = $1;
print "$link\n";
while ($link !~ /\w$/)
{
$link = substr ($link,0,length($link)-1);
print "$link\n";
}
$text =~ s/$link/<a href=mailto:$link>$link<\/a>/;
}
print $text;
The problem is that the output looks like this:
Email me at <a href=mailto:karic at lclark.ed>karic at lclark.ed</a>u,
or at <a href=mailto:wwwadmin at lclark.ed>wwwadmin at lclark.ed</a>u, dude.
How come the final [\w\-] doesn't match the u in edu?
I'm stumped.
-kari.
--
Kari Chisholm
Creative Director for New Media
Lewis & Clark College
Portland, Oregon
http://www.lclark.edu
TIMTOWTDI
More information about the Pdx-pm-list
mailing list