cc: @Ramin Gharib since I saw you have been committing similar optimizations. We recently faced a few issues with the regex extract functions and I was planning to commit upstream fixes for them but looks like you've fixed a bunch. Thanks!
I have a few more in the pipeline on a few performance related re-writes but they're a bit bigger in scope, I'll raise them if this gets in.