Your task, should you choose to accept it, is to write a Perl regular expression that for a given string, will return the first occurrence of a character that is not consecutively duplicated. In other words, both preceded AND succeeded by characters different from itself (or start/end of string respectively).
Example:
IN: aabbcdecc
OUT: c
Please note that “not consecutively duplicated” does not mean “anywhere in the string”.
NOTE: it must be a pure regex expression. E.g. the solution that obviously comes to mind (clone the string, delete all the duplicates, and print the first remaining character) does not count, although it solves the problem.
The question is inspired by my somewhat off-topic answer to this: How can I find the first non-repeating character in a string using Perl?
Get the 2nd capture. (Will return an empty string if every character is consecutively duplicated.)
Test cases:
Or (will not match if every character is consecutively duplicated.)