That seems super complicated - why not `pattern = "\\.[rR]$"`