Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for s (DOT_ALL) regex option SERVER-2943

  • Loading branch information...
commit 07502672a2f8883081b20ec811fb86664d8ad3bb 1 parent fa79ec7
@RedBeard0531 RedBeard0531 authored
Showing with 10 additions and 0 deletions.
  1. +2 −0  db/matcher.cpp
  2. +8 −0 jstests/regex2.js
View
2  db/matcher.cpp
@@ -40,6 +40,8 @@ namespace {
options.set_multiline(true);
else if ( *flags == 'x' )
options.set_extended(true);
+ else if ( *flags == 's' )
+ options.set_dotall(true);
flags++;
}
return options;
View
8 jstests/regex2.js
@@ -60,3 +60,11 @@ assert.eq( 1 , t.find( { a : {$regex: a} } ).count() , "obj C D" );
assert.eq( 1 , t.find( { a : {$regex: b} } ).count() , "obj C E" );
assert.eq( 2 , t.find( { a : {$regex: a , $options: "i" } } ).count() , "obj C F is spidermonkey built with UTF-8 support?" );
+// Test s (DOT_ALL) option. Not supported with /regex/opts syntax
+t.drop();
+t.save({a:'1 2'})
+t.save({a:'1\n2'})
+assert.eq( 1 , t.find( { a : {$regex: '1.*2'} } ).count() );
+assert.eq( 2 , t.find( { a : {$regex: '1.*2', $options: 's'} } ).count() );
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.