PascaleBeier / bootstrap-validate

A simple Form Validation Utility for Bootstrap 3 and Bootstrap 4 for Humans.
https://bootstrap-validate.js.org
MIT License
136 stars 54 forks source link

Regex Rule cannot handle all Expressions #57

Closed PascaleBeier closed 3 years ago

PascaleBeier commented 4 years ago

Because of how this library handles regex (as a string, that is), not all regular expressions work.

Keep in mind that you leave out the Quanitifiers "/" "/g" etc and check your own regexes for JavaScript at regex101.

anscharivs commented 4 years ago

Seems like it has many problems with complex regex. I'm trying to validate with these regex:

For a simple name (example: Oscar): /^[ÁÉÍÓÚÑA-Z][a-záéíóúñ]+(\s+[ÁÉÍÓÚÑA-Z]?[a-záéíóúñ]+)*$/g

For a password (example: Abc12#45) /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*]{8,}$/g

And is not working! :(

PascaleBeier commented 4 years ago

@VegaMex

Your first regex works:

https://jsfiddle.net/57pyawLn/4/

Keep in mind you are using JavaScript. Please validate your Regex! :) A good tool is regex101.

anscharivs commented 4 years ago

@PascaleBeier

I really needed the quantifiers, and the second one only works without the quotes, but if the library uses strings there's nothing to do. Thanks for reply.

PascaleBeier commented 3 years ago

see #65