sub("((?:[^H]*H){2}[^H]*)H", "\\1.","AHBHCHEFHDGA")
Standard input is empty
[1] "AHBHC.EFHDGA"
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!