Hi, On Fri, Dec 21, 2012 at 8:39 AM, Feng He <fen...@nsbeta.info> wrote:
> Hello, > > I have a string like: dns\.support.dnsbed.com > I want to translate it to a regular email address: dns.supp...@dnsbed.com > > > if ($string =~ /^(.*?)(?<!\\)\.(.*)$/) { > my $user = $1; > my $tld = $2; > return $user . '@'. $tld; } > > But this won't work correctly. I got: > d...@support.dnsbed.com > > Where do I get wrong? Thanks. > > Any of these will work: my $string = 'dns\.support.dnsbed.com'; $string =~ s/(.+?)\\(\..+?)\.(.*)$/print "$1$2\@$3"/e; ## OR if ( $string =~ m/(.+?)\\(\..+?)\.(.*)$/ ) { print $1, $2, '@', $3; } > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Tim