我有一个字符串变量,其中包含类似ABCD.asd.qwe.com:/dir1
. 我想提取ABCD
部分,即从开始到第一次出现的部分.
。问题是在.
. 所以我创建了这个正则表达式。
if($arg =~ /(.*?\.?)/)
{
my $temp_name = $1;
}
但是它给了我空白字符串。逻辑是:
.*? - any character non-greedily
\.? - till first or none appearance of .
有什么问题?