Fixed a bug where using an illegal group reference in reg_replace caused a java exception.