-2

I have below regular expression code -

const testRegex = new RegExp("\$(?:ne|eq|lte?|gte?|n?in|mod|all|size|exists|type|slice|x?or|div|like|between|and|where:|==|;sleep|comment:|.insert|.match|while|&pass)", 'i');

const payload = {"$ne": null}; 
const payloadString = JSON.stringify(payload);
const res = testRegex.test(payloadString);
console.log(res); // it prints false , that means it is not matching 

However , when I run same regex and input in regex101 , it retuns the match as shown in below screen shot

regex101test

Can anybody please help what I am missing here ?

Atul
  • 1,440
  • 3
  • 27
  • 66

0 Answers0