fixed a bug in RegexEncoder