Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串,我需要将其拆分为三个字符的块。谷歌搜索发现以下代码,它工作正常:
$input = "DEADBEEF"; @output = (); my @output = ( $input =~ m/.{3}/g ); print $_."\n" foreach (@output);
我是 Perl 初学者;有人可以向我解释一下这个表达式的$input =~ m/.{3}/g作用吗?
$input =~ m/.{3}/g
$input - scalar variable =~ - apply regular expression m - Match (in list context so return a list of matched substrings) / - start of expression . - any character {3} - 3 times / - end of expression g - globally