in reply to Replace every character that occurs more than one and their occurences are even
The s/// operation in your code contains only one set of parens in the regex match, but uses $2 in the replacement, which will always be an empty string. There's no mention of "XY" in the replacement. And given this type of regex pattern:
strings that will match it include: "aa", "abab", "ababab", "abcabc", "abcabcabc", "abcdabcd", etc. -- that is, whenever any string of one or more letters is repeated one or more times -- but there will be quirks: "abababab" will be matched as "abab" occurring twice (not "ab" occurring four times)./(\w+)\1+/
|
|---|