Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by GrandFather (Saint)
on Sep 14, 2020 at 12:32 UTC ( [id://11121727]=note: print w/replies, xml ) Need Help??


in reply to regex, find words that occur more than once.

You don't tell us why which leaves plenty of room for guessing. If you don't need to use a regex you can get a count of word use like this:

use strict; use warnings; my $text = "and him him lad has him done and john has has"; my %words; ++$words{$_} for split /\s+/, $text; print "$_: $words{$_}\n" for sort keys %words;

Prints:

and: 2 done: 1 has: 3 him: 3 john: 1 lad: 1

If that's not helpful for your immediate problem you might like to give us some more context.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found