Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by kennethk (Abbot)
on Sep 15, 2020 at 13:38 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121793]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-19 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found