put regex into function form