Fix bug in counting slashes in a regexp.

Fixes #391.