Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: How do you find duplicates in a string?by davido (Cardinal) |
on Sep 21, 2006 at 16:20 UTC ( [id://574180]=note: print w/replies, xml ) | Need Help?? |
You can use regular expression capturing, and backreferences.
Limitation: Words can contain only alpha characters. You could modify the expression: [[:alpha:]] so as to include what you might consider to be legal word characters, such as ' (apostrophe) and - (hyphen). I used the /x modifier to facilitate grouping the regular expression's sub-expressions into meaningful clusters so that it's easier to read. Hope this helps! Dave
In Section
Seekers of Perl Wisdom
|
|