Added a constructor from RegExp with tests.