val_matches function

Test that the user's expression matches a regular expression.