Fixed problem with regexp/param matching

* Previously, the last char of a regexp match group would be lost - this change fixes that
* Added test