$x="b\xe2r.a\xe2.bar"; $_=$x; s/[a\xe2][a\xe2]/\xe2/; print "first try: $x -> $_"; $_=$x; s/[a\xe2]{2}/\xe2/; print "second try: $x -> $_";