Regular Expression For Consecutive Duplicate Bigrams
问题 My question is a direct extension of this earlier question about detecting consecutive words (unigrams) in a string. In the previous question, Not that that is related could be detected via this regex: \b(\w+)\s+\1\b Here, I want to detect consecutive bigrams (pairs of words): are blue and then and then very bright Ideally, I also want to know how to replace the detected pattern (duplicate) by a single element, so as to obtain in the end: are blue and then very bright (for this application,