Answer the question
In order to leave comments, you need to log in
What RegExp expression is suitable for checking a string with the following conditions?
Help me write a regular expression to validate a string according to the following conditions:
1. The string can only contain characters - a, b, c, d, e, f.
2. The string can only contain numbers greater than 3 (from the number 3 to infinity).
3. The string must start with an alphabetic character.
4. Repeating (identical) alphabetic characters in a row cannot be more than two.
5. The number cannot be after two consecutive (identical) alphabetic characters. ("aa3" for example, should not pass the test).
For better understanding, here are a few examples:
"abcbdbefab" - TRUE
"eebbaaccddeeff" - TRUE
"f3b4c5d6e712f3" - TRUE
"aab3a3eef" - TRUE
"aaabcccd"
"f7bb6e" - FALSE (cannot be a digit after two identical alphabetic characters in a row)
"3aab5" - FALSE (cannot have a string start with a digit)
"a2b1" - FALSE (cannot use numbers less than 3)
I hope I explained clearly.
I really ask for your help!
Thanks in advance.
Security Code:
const string = "d3bc55aab32ef" // такая строка должна вернуть TRUE так как она подходит под все 5 пунктов
const regExp = ???
return regExp.test(string) // return TRUE
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question