I need RegExp expression, which selects each letter once in the sentence (case insensitive). Can you help me?
Input string is:
AaAaaAaaabbacdaasccasddasdascasdasZz
Result must be (in any order):
abcdsz
UPD: ok, i got it. No RegExp solution. Programmatically solution below. (Qt)
It is possible, with two caveats, each letter is in their separate match, and there is no guarantee about the case of the character (the last appearance of the character, uppercase or lowercase regardless, will be picked).
(.)(?!.*\1)
QRegExp
implements backreference, and look-ahead, so the regex above should work.
It should be used with Qt::CaseInsensitive
option on.
.
in QRegExp by default matches any character without exception (which is equivalent to having s
option on all the time in Perl, PCRE, Java, etc.), so depending on your requirement, you might want to strip all space characters in the string first..
Demo at regex101 (it uses PCRE engine, but there should be no difference in behavior for this regex)