[SERVER-3720] regex match null character Created: 30/Aug/11  Updated: 22/Feb/16  Resolved: 22/Feb/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Duplicate Votes: 2
Labels: regex
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File null_regex.js    
Issue Links:
Duplicate
duplicates SERVER-18824 Support matching text that has embedd... Closed
is duplicated by SERVER-19177 Find using regexp fails when the stri... Closed
Participants:

 Description   

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} )
> 



 Comments   
Comment by Aaron Staple [ 30/Aug/11 ]

Also, if you look above there seem to be some problems handling a regular expression string containing an internal null.

Generated at Thu Feb 08 03:03:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.