Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by GrandFather (Sage)
on Sep 14, 2020 at 12:32 UTC ( #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
Node Status?
node history
Node Type: note [id://11121727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-11-26 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?