in reply to Regex help \b & \Q
Another way:
c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(dd); ;; my ($kw) = map qr{ (?i) (?: $_) }xms, join q{|}, map quotemeta, reverse sort qw(.NET C C++) ; ;; my $title = 'C xC Cx C C C C++ xC++ C++x C++ C++ C++ .NET x.NET .NETx + .NET .NET .NET c c++ .net' ;; my %count; $count{ uc $1 }++ while $title =~ m{ (?<! \S) ($kw) (?! \S) }xmsg; dd \%count; " { ".NET" => 5, "C" => 5, "C++" => 5 }
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex help \b & \Q
by Anonymous Monk on Apr 14, 2016 at 12:38 UTC | |
by AnomalousMonk (Archbishop) on Apr 14, 2016 at 12:48 UTC | |
by Anonymous Monk on Apr 14, 2016 at 13:13 UTC |