So... this is safe to run on arbitrary user-supplied data, right?  Because full blown Ruby regexp allows evaluated code embedded in some cases.  Probably best to at least comment on the security implications here so that nobody changes it to alter the security commitment of the code in future. ;)