The key factor is to analyze the preg_match condition and see if there are any characters that escape the matches.
Afterwhich, construct a query that is similar to `1=1` of the usual sql injection and terminate the query.