For example (a|b)\1 to match aa and bb but not ab or ba. (Check if RE2 implements these.)
(a|b)\1
aa
bb
ab
ba