Sunday, March 13, 2016
perl의 regular expression에서 number of matches 얻는 법
다음과 같이 하면 됨
my $s = "Hi. This is me.";
my $n = scalar( @{[ $s=~/i/g ]} );
실행하면 $n 의 결과값은 3이 나옴
레퍼런스 :
Is there a Perl shortcut to count the number of matches in a string?
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment