New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug with regex #699
Comments
Hey there. I see the issue yeah... Have you tried with a simplified regex? Not sure what could be the issue exactly atm. |
Interestingly enough, doing just this works: reg: v => new RegExp(/^((?!\s{2,}).)*$/ig).test(v), |
Also does this happen inside a Webpack App or you have only tried in the browser? Like a fiddle or something? |
Hi. I have tried with simplified regex and found that the flag "g" is doing this effect. If we remove it - then it works. |
Tried in the App, in JSFiddle and in browser. And in browser it works correctly as you could see. |
running into this aswell, in addition to regex flags, it seems if the regex is is stored in a variable it will also fail. export const validator = v => new RegExp(/.../ig).test(v) // works
const regex = new RegExp(/.../ig)
export const validator = v => regex.test(v) // fails |
test called multiple times on the same global regular expression instance will advance past the previous match. You can get around this by setting RegExp.lastIndex = 0 before each match is attempted, but be wary of this behavior. |
read more (here)[vuelidate#699 (comment)]
JSFiddle: https://jsfiddle.net/awetv6zk/
Video: https://drive.google.com/file/d/1HJl3HgASyAy4Jlp2oxh-hoWQXpDm0uZL/view
Video: https://drive.google.com/file/d/1qzOBIv3uArafG9n0wBQlHbRztFZs2nyt/view
This expression should fail only if we have 3 or more white spaces in the string. And it works correctly in browser console.
Even if we copy/erase/paste some string into the input it still fails or not with 50% chance :[
The text was updated successfully, but these errors were encountered: