Use branching to avoid comparing anew to the same regexp