Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3720

regex match null character

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying

      I think we are starting to support strings with null characters SERVER-1300. Would be nice if we could match these characters using regular expressions. Not sure if this is supported in pcre though.

      > c.drop()
      true
      > a = 'a\0b';
      ab
      > c.save( {a:a} )
      > c.find( {a:a} )
      { "_id" : ObjectId("4e5c56e5abcf05c6aa443a91"), "a" : "a" }
      > r = new RegExp( 'c|a' )
      /c|a/
      > c.find( {a:r} )
      { "_id" : ObjectId("4e5c56e5abcf05c6aa443a91"), "a" : "a" }
      > r = new RegExp( 'c\0|a' )
      /c|a/
      > c.find( {a:r} )
      > c.save( {a:r} )
      > c.find( {a:r} )
      Mon Aug 29 20:21:01 warning: unknown regex flag:|
      Mon Aug 29 20:21:01 warning: unknown regex flag:a
      { "_id" : ObjectId("4e5c571babcf05c6aa443a92"), "a" : /c/ }
      > 
      
      
      > r = /a\x00/
      /a\x00/
      > a.match(r)
      [ "a\u0000" ]
      > c.find( {a:r} )
      > 
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: