Pattern substitutions for string manipulation