$string='dns\.support.dnsbed.com';
print "$string\n";
if ($string =~ /^(.*?)\\\.(.*?)(?<!\\)\.(.*)$/) {
print $1.".".$2."@".$3;
}
Output:
dns\.support.dnsbed.com
[email protected]
我猜你遇到的是转义的问题。。。
-----Original Message-----
From: Feng He [mailto:[email protected]]
Sent: Friday, December 21, 2012 3:39 PM
To: [email protected]
Subject: Help with a regex
Hello,
I have a string like: dns\.support.dnsbed.com I want to translate it to a
regular email address: [email protected]
if ($string =~ /^(.*?)(?<!\\)\.(.*)$/) {
my $user = $1;
my $tld = $2;
return $user . '@'. $tld;
}
But this won't work correctly. I got:
[email protected]
Where do I get wrong? Thanks.
--
To unsubscribe, e-mail: [email protected] For additional commands,
e-mail: [email protected] http://learn.perl.org/