Combine regex functions into a single function