 			var timestamp = Int64(val.timeIntervalSince1970)
 			size += try write(value: &timestamp, toStream: stream)
 			
-//		case _ as NSRegularExpression: fatalError("Not Implemented (TODO)")
+		case let regexp as NSRegularExpression:
+			size += try write(elementType: .utcDateTime, toStream: stream)
+			size += try write(CEncodedString: key, toStream: stream)
+			size += try write(CEncodedString: regexp.pattern, toStream: stream)
+			size += try write(CEncodedString: bsonRegexpOptionsString(fromFoundationRegexp: regexp), toStream: stream)
 			
 		case let str as String:
 			size += try write(elementType: .utf8String, toStream: stream)

		
		/* Let's get the UTF8 bytes of the string. */
		let bytes = [UInt8](str.utf8)
		guard !bytes.contains(0) else {throw BSONSerializationError.unserializableKey(str)}
		
		let curWrite = bytes.withUnsafeBufferPointer { p -> Int in return stream.write(p.baseAddress!, maxLength: bytes.count) }
		guard curWrite == bytes.count else {throw BSONSerializationError.cannotWriteToStream(streamError: stream.streamError)}

	private class func write(elementType: BSONElementType, toStream stream: OutputStream) throws -> Int {
		var t = elementType.rawValue
		return try write(value: &t, toStream: stream)
	}
	
	private class func bsonRegexpOptionsString(fromFoundationRegexp foundationRegexp: NSRegularExpression) -> String {
		var result = ""
		
		let opt = foundationRegexp.options
		if  opt.contains(.caseInsensitive)          {result += "i" /* Case insensitive matching */}
		if !opt.contains(.anchorsMatchLines)        {result += "m" /* Multiline matching. Not sure if what we've set corresponds exactly to the MongoDB implementation's... */}
		/* Unsupported in foundation flag: x (verbose) */
		result += "l" /* We consider this flag to be a default, unremovable behaviour in Foundation (makes \w, \W, etc. locale dependent) */
		if  opt.contains(.dotMatchesLineSeparators) {result += "s" /* Dotall mode ('.' matches everything). Not sure if exactly equivalent to Foundation option... */}
		if  opt.contains(.useUnicodeWordBoundaries) {result += "u" /* Make \w, \W, etc. match unicode */}
		/* Ignored foundation options: .allowCommentsAndWhitespace, .ignoreMetacharacters, .useUnixLineSeparators */
		
		return result
	}
	
}
