code: public void writeRegex(Pattern pattern) throws IOException {
  		_writeArrayFieldNameIfNeeded();
  		_verifyValueWrite("write regex");
  		_buffer.putByte(_typeMarker, BsonConstants.TYPE_REGEX);
  		_writeCString(pattern.pattern());
  		_writeCString(flagsToRegexOptions(pattern.flags()));
  		flushBuffer();
  	}
docs: Write a BSON regex
  
  @param pattern The regex to write
  @throws IOException If an error occurred in the stream while writing