Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: regex, find words that occur more than once.

by kennethk (Abbot)
on Sep 15, 2020 at 13:38 UTC ( #11121793=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    while($text=~/\b(\w+)\b(?=.*\b\1\b)/g){
        $words{$1} //= 1;  # initialize empty value to one
        $words{$1}++;
    }
    
  2. or download this
    use strict;
    use warnings;
    ...
    foreach my $key (keys %words){
        say "$key: $reps{$key}";
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11121793]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2020-11-26 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?