Fish Wang says to YSITD
s/(.)\1+/[$1]/g