2: Using functions instead of strings as the replacement in sub(). If you're looking to do a fair amount of conditional logic in your replacement, it might be more easily written by having a function do it, rather than attempt to do it all with a regex.