C# 2.0 Regex?

92 views
Skip to first unread message

Mark Shaw

unread,
Apr 29, 2015, 3:33:36 PM4/29/15
to mongod...@googlegroups.com
How does one do this using the new driver?

// Regex

var search = MongoBuilders.Query.Matches("Symbol", new BsonRegularExpression(string.Format("/(^{0}.*)|(.*{0}$)/", filterText)));

Craig Wilson

unread,
Apr 29, 2015, 6:27:26 PM4/29/15
to mongod...@googlegroups.com
There is a FilterDefinitionBuilder you would use, as documented here: http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/definitions/#filter-definition-builder

Builders<BsonDocument>.Filter.Regex("Symbol", string.Format("/(^{0}.*)|(.*{0}$)/", filterText));

Craig
Reply all
Reply to author
Forward
0 new messages