After matching some code with a Semgrep pattern, you can use metavariable-regex to see if the matched part also matches a regular expression.
metavariable-regex