Basic algorithms for string manipulation