updated regex serialization code to use toString rather than source