Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to remove duplicate characters in a string in place

by duelafn (Parson)
on Feb 20, 2016 at 17:55 UTC ( [id://1155721]=note: print w/replies, xml ) Need Help??


in reply to How to remove duplicate characters in a string in place

Still executes in a loop, but gets all instances of each letter each time (thus avoids the even/odd issue you have).

use 5.010; my $str = "abcdefghiaabccdjklm"; my $substr; $substr = "" while $str =~ s/(.)(?:(.*?)\1(?{ $substr .= $^N }))+/$sub +str/; say $str;

Good Day,
    Dean

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2026-03-16 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.