Correct legalReference regex

Fixes #850. Regression test added as well.