javascript - Need a regex that accepts any text that contains at least 3 alphabets -


i need regular expression accepts string contains @ least 3 english alphabets. alphabets can anywhere in string.

test cases:

should return true for:

 abc test number 123 $@!!. 123abc289389798 

should return false for:

 ab ab213823897 

edit: sorry, should clarify needs 3 english alphabets. alphabets can anywhere in string.

how this?

[a-za-z].*[a-za-z].*[a-za-z] 

the [a-za-z] matches character a-z or a-z. regex guarantees have 3 of these characters. .* matches number of character, 3 alpha characters can consecutive or have before/after/in between.

test out @ regex tool http://gskinner.com/regexr/

you can consolidate this:

([a-za-z].*){3} 

edit: replaced \w [a-za-z] , added explanation.

edit2: @nhahtdh, removed .* beginning , end since need match, not coverage of whole string.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -