How do I check for adjacent characters and if they match, delete one?

Have you check the above thread in the @Yoichi post @Vlad_Svitelskyi