My sample code (the solution is actually the regex /^[a-zA-Z0-9]{6,20}$/) removes trailing line seperators (however they may currently be defined). A blank line will comprise two consecutive line seperators and will result in an invalid string being detected - which is consistent with OP's criteria (and original code).
Note that at least part of the rationale for posting a "complete sample" is to show others with a technique for providing stand alone code to demonstrate a problem or solution. The line handling code is incedental to the OP's question, but is an important part of a technique for providing test data.
Hmm, ok I'll go get that coffee now :)
In reply to Re^3: how should i test whether a string contains between 6 and 20 letters and numbers
by GrandFather
in thread how should i test whether a string contains between 6 and 20 letters and numbers
by keiusui
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |