Regex stumper?

Kari Chisholm karic at
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, or at wwwadmin at, dude.

And, make it output this:

	Email me at <a href=mailto:karic at>karic at</a>, or
	at <a href=mailto:wwwadmin at>wwwadmin at<a/>, dude.

My code-snippet is this:

$text = "Email me at karic\, or at wwwadmin\,

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 Chisholm
Creative Director for New Media
Lewis & Clark College
Portland, Oregon

More information about the Pdx-pm-list mailing list