using regex as conditional operator