Multiple versions of same function

Good question. An off-the-top-of-my-head answer is to write your function with argument parameters that can vary with the pattern. I can't tell without reproducible example, called a reprex whether you need to go further into a full-fledged parser, but that's another option.