perl -Mre=debug -le 'print /(.)[^\1]\1/ ? "match" : "no match"' Freeing REx: `","' Compiling REx `(.)[^\1]\1' size 19 Got 156 bytes for offset annotations. first at 3 1: OPEN1(3) 3: REG_ANY(4) 4: CLOSE1(6) 6: ANYOF[\0\2-\377{unicode_all}](17) 17: REF1(19) 19: END(0) #### perl -le '$_ = "B\1B"; print /(.)[^\1]\1/ ? "match" : "no match"'