I like the idea of a regex, but if I had to do it this way… I’d figure out the parameters, probably pulling into their own function.
I haven’t tested it. I’ve probably missed something, but I think it’s close