|
| [WD18] Need help with regular expression |
| Débuté par guest, 15 avr. 2014 23:13 - 3 réponses |
| |
| | | |
|
| |
| Posté le 15 avril 2014 - 23:13 |
Hi,
To check a password strength I want to use this regular expression
"^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\W])(?=.*[\d]).*$"
But the MatchRegularExpression always return false ?
The rules would be: * Min length 8 * At least 1 Capital letter * At least 1 lower case letter * At least 1 symbol * At least 1 digit
When I use the following site https://www.debuggex.com to test the Regular expression it matches OK when I use a test string of "fnLny1sd+"
Any idea why Windev returns false every time ?
Thanks Danny [attachment 882 regex.png] |
| |
| |
| | | |
|
| | |
| |
| Posté le 16 avril 2014 - 03:47 |
I have no idea. Maybe "positive lookahead" "(?=" is incompatible with windev. I
Maybe you can can divide the problem. It's simplier to understand, easier to read and easier to modify, and i think it has the same process time:
MatchRegularExpression(MyPasswordString, "regConsant_Check_if_has_numbers") MatchRegularExpression(MyPasswordString, "regConsant_Check_if_has_lowercase") MatchRegularExpression(MyPasswordString, "regConsant_Check_if_has_uppercase") MatchRegularExpression(MyPasswordString, "regConsant_Check_if_has_symbols")
IMHO.
Regards, José Antonio. |
| |
| |
| | | |
|
| | |
| |
| Posté le 16 avril 2014 - 19:29 |
Hi Danny,
Indeed, I had problems with regular expressions in WD too. The problem is that this is not a fully-flexible regular expression parser. MatchRegularExpression() really tries to "Match". If it does not absolutely match, it returns false, even if in fact, your regular expression could return totally good values.
I forgot to send them a report on this some weeks ago when I saw the problem. I'll do so and suggest them to implement a full-fledged regexp parser. That would be more than useful.
Best regards, Alexandre Leclerc
PS: My regexp were all validating correctly on many websites that help building reg. expressions. But they were systematically not working in WD. |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 962 messages |
|
| Posté le 30 avril 2014 - 01:35 |
hello Danny, you can try to use the vbscript.regexp automation object like that :
sPassword is a string MyRegexp is a object OLE "vbscript.regexp" oMatches is a dynamic object OLE MyRegexp>>GLOBAL = True
MyRegexp>>Pattern = "^(?:(?=.*[a-z])(?:(?=.*[A-Z])(?=.*[\d\W])|(?=.*\W)(?=.*\d))|(?=.*\W)(?=.*[A-Z])(?=.*\d)).{8,}$" sPassword = "MyPassword" oMatches = MyRegexp>>Execute(sPassword) IF oMatches>>Count = 1 THEN Trace (sPassword," : Passord OK") ELSE Trace (sPassword," : Passord NOK") sPassword = "MyPassword1?" oMatches = MyRegexp>>Execute(sPassword) IF oMatches>>Count = 1 THEN Trace (sPassword," : Passord OK") ELSE Trace (sPassword," : Passord NOK")
Friendly, J.P |
| |
| |
| | | |
|
| | | | |
| | |
|