Add the match() function.

This brings about a major refactoring, to factor out common code for
regex compiles and matches.
.gitlab-ci.yml not found in this commit