Fix a bug where first char of pattern doesn't match and causes crash.