Wrapping regex's with proxies isn't working

Angel Scull scull06 at gmail.com
Thu Nov 10 13:59:15 UTC 2016


I’ve tried this code and seems that there is some weird type checking somewhere that causes this exception. 

TypeError: Method RegExp.prototype.exec called on incompatible receiver [object Object]

let pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/;

let patternProxy = new Proxy(pattern,{});

patternProxy.test('myusername at mycompany.com')

More information about the es-discuss mailing list