I need to use a regex result as well as its fail reason. Consider following:
myStr = "loremipsum5lorem";
function check(x) {
x = /^[a-zA-Z]$/.test(x);
console.log(x, reason);
};
console.log(check(myStr));
Should output something like this:
false, non-alphanumeric character at index 11
How can I get the reason?