Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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

by GrandFather (Saint)
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;


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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2021-02-27 13:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found