Tips, Tricks and Tools
... and Thoughts
(Move to ...)
Home
All Posts
Firefox Extensions
JavaScript Compiler and Encoder
Bulk Player for YouTube
Misc Tools
Support
▼
Monday, June 17, 2019
Perl: Count the appearance of a specific character in a string
For example, to count the appearance of character ':' in a string --
my $str = "a:b:c:d:e:f:g";
my $count = ($str =~ tr/://);
print $count, "\n";
The output will be 6.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment