I think on multiple matches we should return `null` or raise an error since returning the first one is just guessing (unless they're all the same I suppose?).

I'd suggest skipping caching unless we actually encounter performance issues -- how slow can splitting and matching a string be? I suspect JS engines that JIT stuff can probably optimize this kind of code pretty well (although who knows for sure?)