in reply to Re^4: how should i test whether a string contains between 6 and 20 letters and numbers
in thread how should i test whether a string contains between 6 and 20 letters and numbers
I must be being particuarly dense today because I just don't understand where you are coming from with this!
Consider the following two variants of the code I posted:
Given: __DATA__ Success Invalid string! ... { if (/^[a-zA-Z0-9]{6,20}\z/) { ... prints: Invalid string: >Success < Invalid string: > < Invalid string: >Invalid string! < and ... { chomp; if (/^[a-zA-Z0-9]{6,20}\z/) { ... prints: Success: >Success< Invalid string: >< Invalid string: >Invalid string!<
Where is the problem? At the end of the day both variants tag the invalid strings invalid and the valid string valid. For the sample code the \z variant with no chomp prints the line end characters from the input data - but that was not important to the sample code, in fact it is distracting.
We have no information about why OP needs this code (although validating passwords does seem likely) and it's not clear to me what assumptions I am making that would cause a clever cracker to continue his career. Would you care to sketch a scenario showing how the solution is substandard?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: how should i test whether a string contains between 6 and 20 letters and numbers
by brian_d_foy (Abbot) on Jan 30, 2006 at 03:24 UTC | |
by GrandFather (Saint) on Jan 30, 2006 at 19:40 UTC |