Removed a bug when inserting a char in the middle of the pattern.