Closed SittiphanSittisak closed 7 months ago
Try "\[". Match uses a regular expression. "[" is a special character an needs to be escaped
Is there another special character in mongo_dart that I should know? I can use a sub string every time I use match but is possible to make this handle on this package?
This has nothing to do with mongo_dart. It is the Regular Expression syntax. Search in internet the documentation or give a look to the RegExpr class in dart.
Thank you, I got it.
Update using this before using match
RegExp.escape(keyWord)
Hi, for this issue I must use RegExp.escape
for every keyword that is used for the .match
method.
If not use this and the keyword contains a character, it will always error.
So, is it possible to add using the RegExp.escape
in the .match
method?
like this
SelectorBuilder match(String fieldName, String pattern,
{bool? multiLine, bool? caseInsensitive, bool? dotAll, bool? extended}) {
_addExpression(fieldName, {
'\$regex': BsonRegexp(RegExp.escape(pattern),
multiLine: multiLine,
caseInsensitive: caseInsensitive,
dotAll: dotAll,
extended: extended)
});
return this;
}
I have added a new parameter that does what you want. You have to updat the dependencies so that you will use the last version of the mongo_dart_query package.
I close this issue, feel free to reopen it if needed.
I get this error when use it.