P is for Practical | |
PerlMonks |
Re: Determining uniqueness in a string. (2x)by tye (Sage) |
on Oct 01, 2005 at 06:00 UTC ( [id://496594]=note: print w/replies, xml ) | Need Help?? |
The fastest one I found (the only one I tried that was faster than the /(.).*\1/ variations) was certainly not the shortest:
But it was about twice as fast. Update: Added the '^' to make failure cases fast. The (?=.*?0) asserts that $digits contains a '0'. If that fails, then the regex fails. If a '0' is found, then (since that was a look-ahead assertion), we start over at the beginning of $digits and (?=.*?1) asserts that $digits contains a '1'. etc. - tye
In Section
Seekers of Perl Wisdom
|
|