In perl how do I get all matching result /g?
$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
精彩评论