something like
DB<98> say "$_:\t", $_ =~ s/(\w\w).*\@.*(\.\w*)/$1...\@...$2/r for q +w/someone@example.co.uk andrew.test@some.company.co.uk jo@abc.com/ someone@example.co.uk: so...@....uk andrew.test@some.company.co.uk: an...@....uk jo@abc.com: jo...@....com
?
YMMV
FWIW your code is (mostly) OK, but you should really always do it in an if-block to test for a successful match first
if( $em =~ /^(\w[\w|\.]).*@(\w\w).*\.(\w+)$/ ) { $em = $1 . '.' x (length($name) - 2) . "\@$2" . '.' x (length($com +p) - length($3) - 2) . $3; }
and you might get bitten by variable interpolation if you don't escape the "@" in a regex: \@
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re: Counting characters within regexp
by LanX
in thread Counting characters within regexp
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |