Reputation: 51
This regular expression /^(?:([A-Za-z])(?!\1))*S(?:([A-Za-z])(?!\1{2})){3,30}\
not working. Why?
I need a string:
{3,30}
/^(?:([A-Za-z])(?!\1))
/^(?:([A-Za-z])(?!\1{2}))
E.G.
Upvotes: 1
Views: 65
Reputation: 12731
Look if it satisfies your requirements:
^(?:([A-Za-z])(?!\1))(?!.* .* )(?:([A-Za-z ])(?!\2{2})){2,29}$
Your reference to the second captured group was wrong: \1
instead of \2
.
Other than that I excluded spaces in the second negative lookahead.
I also fixed the length since the quantifier doesn't apply to your first group.
You can test it here https://regex101.com/r/Y1AT1L/1
Upvotes: 1