Can you move the regular expression into a variable that is used by both if statements? I'd like to avoid the duplication.