Hi Friends,
I want a regular expression to validate one password field.
Following are the expressions:
(1) Must be 8-15 alpha numeric characters with no spaces
(2) May not contain more than two consecutive repeated characters
Hi Friends,
I want a regular expression to validate one password field.
Following are the expressions:
(1) Must be 8-15 alpha numeric characters with no spaces
(2) May not contain more than two consecutive repeated characters
what have you tried?
Hi Friends,
please help, I need to complete my deliverable.
Regular expressions are one of my interests.
I think #1 should be easy enough.
But #2 not so much.
Please post what you have so far, l’ll be glad to help as best as I can.
/^[A-Za-z-0-9]{8,15}$/i^(?=[^\s]*?[0-9])(?=[^\s]*?[a-zA-Z])[a-zA-Z0-9]*$
above reg ex I tried its not working.
It rejects all the strings.
because that’s two regexes.
Yes, it sure looks like some kind of mish-mash.
This portion
/^[A-Za-z-0-9]{8,15}$/i
looks OK
My translation is
Because the character class has both A-Z and a-z the “i” case-insensitive is redundant. But other than maybe causing some inefficient resource use it probably won’t break anything.
The other “tacked on” portion
^(?=[^\s]*?[0-9])(?=[^\s]*?[a-zA-Z])[a-zA-Z0-9]*$
doesn’t make much sense to me, but looks to be an attempt at something like
So if you take out the “maybes” and “zero or mores” what is required to match is
So, for example these would match
Not close to a
I’m still not 100% certain that can be done with regex alone. But I am fairly certain that if it can be done it would be a scary looking pattern.
I’m also fairly certain it would need not the “?=” look aheads, but “look behind” which JavaScript does not support but might be possible with a server-side language.
So friends,
Can any one please give me the resultant reg ex.
I have searched entire world but no luck !
^(?!.*(.)\1)[abc]+$
above expression is for avoiding the 2 consecutive characters.
^(?=[^\s]?[0-9])(?=[^\s]?[a-zA-Z])[a-zA-Z0-9]*$
this is to avoid only chars or only numbers.
these are the two expressions i got on internet.
How to combine now ?
I’m not sure how to reject repeated characters without additionally using javascript however there are a few regex tools out there that can help you build up your regex query.
Example https://regex101.com/
Yes, same for me. I think for the amount of time it would take me to come up with a regex - if a regex is even possible at all - it would be a lot easier to split the string and loop through the array(s)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.