'jQuery RegExp always returns false for dynamic regex-string [duplicate]
I am dynamically loading a regex-string from a html-input-element.
I tested the regex-string in some validators and all of them worked completely fine. But when i try to use the regex-string in my jQuery-code it always returns a false after validating.
This is my code (minified):
var eingabe = '[email protected]';
var regex_string = '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i';
var regex_obj = new RegExp( regex_string );
error = regex_obj.test( eingabe ) != true;
console.log(error);
I am completely lost because i cant find the error.....
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
