2013-05-08 208 views

回答

5
$user =~ s/([email protected])/sc/; 

$user =~ s/@/[email protected]/; 

$user =~ s/^[^@]*\K/sc/; # Assumes "@" will always be present. 

當然,如果$user不包含正確的字符串開始與無那些將工作。

$user = "[email protected]"; 

相同

$user = "user" . join($", @domain) . ".com"; 

鑑於@domain不存在,這是一樣的

$user = "user.com"; 

始終使用use strict; use warnings;!你想

my $user = "user\@domain.com"; 

my $user = '[email protected]'; 

建立VAR $user以字符串[email protected]

+0

......或'$ USER =反向(反向($用戶)=〜S/@ \ K/CS/R);':) – ikegami 2013-05-08 21:11:57

+0

似乎不使用的工作:$用戶=「用戶@直播。 COM「; $ user =〜s/^ [^ @] * \ K/sc /; print $ user;返回user.comsc另外兩個返回user.com – 2013-05-08 21:23:17

+0

你確定你的字符串包含'user @ domain.com'嗎?你顯示的代碼不會產生這樣的字符串。始終使用'use strict;使用警告;'! – ikegami 2013-05-08 21:24:25

相關問題