I need to determine if a string contains two or more consecutive alpha chars. Two or more [a-zA-Z]
side by side.
Example:
\"ab\" -> valid
\"a
This should do the trick:
[a-zA-Z]{2,}
Personnaly (as a nooby) I've used:
[0-9][0-9]+.
But the one from Simon, is way better ! =D
I'm pretty sure you can just use [A-z] instead of the [a-zA-Z] to get small and upper case alpha chars http://www.w3schools.com/jsref/jsref_obj_regexp.asp
[a-zA-Z]{2,} does not work for two or more identical consecutive characters. To do that, you should capture any character and then repeat the capture like this:
(.)\1
The parenthesis captures the . which represents any character and \1 is the result of the capture - basically looking for a consecutive repeat of that character. If you wish to be specific on what characters you wish to find are identical consecutive, just replace the "any character" with a character class...
([a-zA-Z])\1
Finds a consecutive repeating lower or upper case letter. Matches on "abbc123" and not "abc1223". To allow for a space between them (i.e. a ab), then include an optional space in the regex between the captured character and the repeat...
([a-z]A-Z])\s?\1