Simplify chain of `if`s by combining regexes