Extracting regex query logic to DB class