1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
{ 
    "description": "Regular Expression type", 
    "bson_type": "0x0B", 
    "test_key": "a", 
    "valid": [ 
        { 
            "description": "empty regex with no options", 
            "canonical_bson": "0A0000000B6100000000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"\", \"options\" : \"\"}}}" 
        }, 
        { 
            "description": "regex without options", 
            "canonical_bson": "0D0000000B6100616263000000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"\"}}}" 
        }, 
        { 
            "description": "regex with options", 
            "canonical_bson": "0F0000000B610061626300696D0000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"im\"}}}" 
        }, 
        { 
            "description": "regex with options (keys reversed)", 
            "canonical_bson": "0F0000000B610061626300696D0000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"im\"}}}", 
            "degenerate_extjson": "{\"a\" : {\"$regularExpression\" : {\"options\" : \"im\", \"pattern\": \"abc\"}}}" 
        }, 
        { 
            "description": "regex with slash", 
            "canonical_bson": "110000000B610061622F636400696D0000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"ab/cd\", \"options\" : \"im\"}}}" 
        }, 
        { 
            "description": "flags not alphabetized", 
            "degenerate_bson": "100000000B6100616263006D69780000", 
            "canonical_bson": "100000000B610061626300696D780000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"imx\"}}}", 
            "degenerate_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"abc\", \"options\" : \"mix\"}}}" 
        }, 
        { 
            "description" : "Required escapes", 
            "canonical_bson" : "100000000B610061625C226162000000", 
            "canonical_extjson": "{\"a\" : {\"$regularExpression\" : { \"pattern\": \"ab\\\\\\\"ab\", \"options\" : \"\"}}}" 
        }, 
        { 
            "description" : "Regular expression as value of $regex query operator", 
            "canonical_bson" : "180000000B247265676578007061747465726E0069780000", 
            "canonical_extjson": "{\"$regex\" : {\"$regularExpression\" : { \"pattern\": \"pattern\", \"options\" : \"ix\"}}}" 
        }, 
        { 
            "description" : "Regular expression as value of $regex query operator with $options", 
            "canonical_bson" : "270000000B247265676578007061747465726E000002246F7074696F6E73000300000069780000", 
            "canonical_extjson": "{\"$regex\" : {\"$regularExpression\" : { \"pattern\": \"pattern\", \"options\" : \"\"}}, \"$options\" : \"ix\"}" 
        } 
    ], 
    "decodeErrors": [ 
        { 
            "description": "embedded null in pattern", 
            "bson": "0F0000000B610061006300696D0000" 
        }, 
        { 
            "description": "embedded null in flags", 
            "bson": "100000000B61006162630069006D0000" 
        } 
    ] 
}