[1.7.x] Fixed #22943 -- Correctly serialize compiled regexes.

Thanks to antialiasis at gmail dot com for the patch.