WriteRegularExpression() public method

Writes a BSON regular expression to the writer.
public WriteRegularExpression ( BsonRegularExpression regex ) : void
regex BsonRegularExpression A BsonRegularExpression.
return void
 public void TestOneRegularExpression()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteRegularExpression("a", new BsonRegularExpression("p", "i"));
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'a' : /p/i }".Replace("'", "\""); ;
     Assert.Equal(expected, json);
 }
 public void TestTwoNestedRegularExpressions()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteStartDocument("nested");
         writer.WriteRegularExpression("a", new BsonRegularExpression("p", "i"));
         writer.WriteRegularExpression("b", new BsonRegularExpression("q", "m"));
         writer.WriteEndDocument();
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'nested' : { 'a' : /p/i, 'b' : /q/m } }".Replace("'", "\"");
     Assert.Equal(expected, json);
 }