Re: regular expression no match on set if subset matches

From: Gunnar Hjalmarsson (noreply_at_gunnar.cc)
Date: 01/24/04


Date: Sat, 24 Jan 2004 04:21:52 +0100

Dave wrote:
> I am trying to define a regular expression to validate a password
> format so that the password is valid if it contains from 4 to 10
> characters except in the one special case where it has the format
> of three letters followed by two numbers.
>
> That is, "abc13edl" is fine but "abc13" is not.
>
> Is there a solution to this

This uses two regexes:

     $_ = 'mypassword';
     print "OK\n" if /^\S{4,10}$/ and !/^[a-z]{3}\d{2}$/i;

> (using the gnu Java regular expression package)?

Have no idea. We talk Perl here.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


Relevant Pages

  • Re: RegularExpression Validation for password in ASP.NET
    ... Can any one help me to write a regular expression to validate the password ... single quote, double quotes, comma). ... 5- Password must be between 8 and 25 characters. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RegularExpression Validation for password in ASP.NET
    ... Can any one help me to write a regular expression to validate the ... single quote, double quotes, comma). ... 5- Password must be between 8 and 25 characters. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Problem with regular expression
    ... I'm trying to validate a password by means of a regular expression. ... guarantee that the password length is between 4 and 8 characters and that it ...
    (microsoft.public.dotnet.languages.csharp)
  • Regular Expressions
    ... I am trying to work out a regular expression which will validate a ... No special characters allowed except for full stop. ... Ros Lee ...
    (microsoft.public.dotnet.general)
  • Re: Regular Expression Function
    ... I want a regular expression to compare sentences and then rate them as ... I have an array with a list of other phrases like so... ... characters will throw things off. ... "In an hour the system will go down for maintenance". ...
    (alt.php)

Loading