Picking up from #8111. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This is mostly so that we don't #include <regex> everywhere (which adds quite a bit of compilation time).