StringCases[text, x___ ~~ "entitle" ~~ y___ :> StringTake[x, -4] ~~ "entitle" ~~ StringTake[y, 5]] or StringCases[text, Repeated[_, 4] ~~ "entitle" ~~ Repeated[_, 5]] Generalizing: paddedString1[text_, string_, left_, right_] := StringCases[text, x___ ~~ string ~~ y___ :> StringTake[x, -left] ~~ string ~~ StringTake[y, right]] and paddedString2[text_, string_, left_, right_] := StringCases[text, Repeated[_, left] ~~ string ~~ Repeated[_, right]]