Fixed index bug in regex parser