Measurement of jet fragmentation in PbPb and pp collisions at $\sqrts_NN=2.76$ TeV