Home > Archive > PERL Beginners > December 2007 > Regex password length
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Regex password length
|
|
| Alfonso Marinmarin 2007-12-12, 7:02 pm |
| Hi all,
I'm trying to create a regex to ensure a minimum password length.
I'm trying this:
$regex= '^.{4,}$'
That work fine exept for, at least, the equal signal (=)
For example, if i try 'my=test", it returns false. If i try 'myte=st',
that works.
If i change 4 for 2 in regex, then the first example works (my=test)
Look like the repetition part doesn't work at all with equals...
Any idea about that problem? Any solution?
Thanks in advance
Alfonso.
| |
| Tom Phoenix 2007-12-12, 7:02 pm |
| On 12/12/07, alfonso.marinmarin@gmail.com <alfonso.marinmarin@gmail.com> wrote:
> I'm trying to create a regex to ensure a minimum password length.
It would seem that you should use the length function. (Also, why
should it matter that the string in question is a password?)
> I'm trying this:
>
> $regex= '^.{4,}$'
Maybe you need qr// ?
> That work fine exept for, at least, the equal signal (=)
>
> For example, if i try 'my=test", it returns false. If i try 'myte=st',
> that works.
>
> If i change 4 for 2 in regex, then the first example works (my=test)
No, I don't think so. The pattern you're giving should match both. Can
you show us the code that does what you're talking about?
print "matched\n" if 'my=test' =~ /^.{4,}$/;
print "matched\n" if 'myte=st' =~ /^.{4,}$/;
Cheers!
--Tom Phoenix
Stonehenge Perl Training
| |
| Alfonso.Marinmarin@Gmail.Com 2007-12-14, 7:02 pm |
| Resolved. All works as spected. The problem was that the source string
wasn't the correct one, not the regex. Was a stupid mistake.
Thanks any way for the reply
Alfonso
On Dec 13, 12:10 am, t...@stonehenge.com (Tom Phoenix) wrote:
> On 12/12/07, alfonso.marinma...@gmail.com <alfonso.marinma...@gmail.com> wrote:
>
>
> It would seem that you should use the length function. (Also, why
> should it matter that the string in question is a password?)
>
>
>
> Maybe you need qr// ?
>
>
>
>
> No, I don't think so. The pattern you're giving should match both. Can
> you show us the code that does what you're talking about?
>
> print "matched\n" if 'my=test' =~ /^.{4,}$/;
> print "matched\n" if 'myte=st' =~ /^.{4,}$/;
>
> Cheers!
>
> --Tom Phoenix
> Stonehenge Perl Training
|
|
|
|
|