+ 1

Regex Error

I don't understand why the 4th case is failed l. Anyone can help me to solve this problem and explain Regex problem https://code.sololearn.com/cnLYivd9ZGtL/?ref=app

18th Apr 2022, 7:09 AM
Akash Agrawal
Akash Agrawal - avatar
5 Réponses
+ 3
Think about what it is you are expressing. Regex("^([a-z]+[A-Z]+[0-9]+){8,20}
quot;) The first part, ([a-z]+[A-Z]+[0-9]+), says, one or more lowercase letters, one or more uppercase letters, one or more numbers. In that order. Then you add a provision. ^([a-z]+[A-Z]+[0-9]+){8,20}$. That means, the above sequence, repeated between 8 and 20 times. And that from the start to the end of the string. The problem is, you do have the above sequence, yes, but only once, not at least eight times.
18th Apr 2022, 8:39 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
There are limits to what you can do with regular expressions. Also, what is still a word in a regular grammar might require an unwieldy expression. It may be that something is possible with advanced techniques such as look-ahead or something. Unfortunately, this are techniques beyond my expertise. To do complex operations on a string, I would use a cascade of predicate matchings (pipe-and-filter). E.g. simply test the string length with the language tools (pwd.length >= 8), and use regex for complicated evaluations. .
18th Apr 2022, 8:51 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 3
My pleasure 🙂
18th Apr 2022, 8:57 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 2
Ani Jona 🕊 if I want user password min length is 8 and Max:12 using regular expression . So what to do
18th Apr 2022, 8:44 AM
Akash Agrawal
Akash Agrawal - avatar
+ 2
Ani Jona 🕊 ok Thanks for solving problem
18th Apr 2022, 8:56 AM
Akash Agrawal
Akash Agrawal - avatar