perl -le '$_ = "B\1B"; print /(.)[^\1]\1/ ? "match" : "no match"'