added compare function for regex