This question is about the regular expression puzzle. I have a list of words with duplicate characters, for example.
stubbornness
raccoon
cooccurred
successful
Note that each of the terms has two sets of repeating letters, for example. "bb", in "stubbornness." I already wrote my script (in ruby), and I can solve my problem using iteration of each character in the code loop.
However, this mysterious task caught my attention ... I wonder if this can be done using regular expression? I am already advising regular expression tutorials and other StackOverflow questions, but I can’t figure out how to report cheating. Here is the desired result:
bb stubbornness
cc raccoon
oo cooccurred
cc successful
. ( sed MacOS, -r Ubuntu -E):
sed -E 's#(.*?)(.)\2(.*)#\2\2 \1\2\2\3#g'
-. ? , .