Regex will surely be your friend here. Do you want to remove from the string, replace them with new random chars, or throw out the password entirely and regenerate a new random string?
I would use character classes for each set of things you want to be track duplicates for, with something like the below.
my $password = 'a8f3%djk$'; # some random string if ($password =~ m/[[:alpha:]]{3,}|\d{3,}|[\^@\(]{3,}/) { # regenerate password }
You could use a character class like [A-Za-z] instead of [[:alpha:]] if you know you will only see ascii character. You will likely have to add to the [\^@\(] character class any other symbols you want. The other option is to exclude anything you don't want to match in that class. Maybe [^0-9A-Za-z] is enough there.
In reply to Re: Removing similar characters
by Kc12349
in thread Removing similar characters
by rspishock
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |