With regex /merg(e)/ as plain text trying to match the "merge" in any text, just results in blank match_group_indexes, hence error. Quick fix can be done via writing regex as /merg(e|a)/ , aka just put that e in the group with some other operations, and this result in matching "e" value.