in reply to Re^4: Regex help \b & \Q
in thread Regex help \b & \Q
Try this:
There might be something a bit more elegant than (?: (?! \S) | (?= [,;])) for the end delimiter, but it was a quick fix.c:\@Work\Perl\monks>perl -wMstrict -le "my $s = '.net, .net; C .NET Cobol .NET C++ .NET .NETER Perl IT x.NET +.net'; ;; for my $kw (qw(.NET C C++)) { my $count = () = $s =~ m{ (?<! \S) \Q$kw\E (?: (?! \S) | (?= [,;])) + }xmsig; print qq{'$kw' $count}; } " '.NET' 6 'C' 1 'C++' 1
Give a man a fish: <%-{-{-{-<
|
|---|