I am trying to find a way to determine which character in my string does not match the regex, is there a way to do so in Javascript?
I've been using the regex object and i was able to determine whether a string matches the regex but i would like to go step further to determine why a string does not match the regex.
any thoughts?
This was what I currently have ... i am just trying to make sure a string only contains the set of characters found in the following regex ... and i would like to see which character does not match.
Here's my code :
var regexTest = new RegExp("^[0-9a-zA-Z\\!\\040\\@\\s\\#\\$\\%\\&\\*\\(\\)\\_\\+\\:\\\"\\<\\>\\?\\-\\=\\;\\'\\,\\.\\\\]+$",g); var bValid = regexTest.test(value); //this will check whether the value is valid ... I've tried using value = value.replace(regexTest,''), but was unable to actually filter out the characters.
"aababb"doesn't match the regex/^a*b*$/? Which character in"aaaccc"doesn't match the regex/^a+b+c+$/? Which character in""(ie: the empty string) doesn't match the regex/a+/?