开发者

In perl how do I get all matching result /g?

开发者 https://www.devze.com 2023-03-28 17:28 出处:网络
$string =开发者_开发百科~ /(pattern)/g; I know I can get the matching result in $1,but how can I get all (/g) and push each result into an array? Is this what you mean?
$string =开发者_开发百科~ /(pattern)/g;

I know I can get the matching result in $1,but how can I get all (/g) and push each result into an array?


Is this what you mean?

$string = 'patternpattern';
@matches_array = $string =~ /(pattern)/g;
print "@matches_array";

That will produce the following output:

pattern pattern
0

精彩评论

暂无评论...
验证码 换一张
取 消