Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by tybalt89 (Prior)
on Sep 14, 2020 at 15:13 UTC ( #11121740=note: print w/replies, xml ) Need Help??


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

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121725 use warnings; use List::Util qw( uniq ); my $text = "and him him lad has him done and john has has"; print "$_\n" for uniq $text =~ /(\b\w+\b)(?=.*?\b\1\b)/g;

Outputs:

and him has

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2020-10-26 18:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (252 votes). Check out past polls.

    Notices?