Regular expression help

Discussion in 'ASP .Net' started by DavidC, Sep 13, 2010.

  1. DavidC

    DavidC Guest

    I am trying to implement a NewPasswordRegularExpression in a ChangePassword
    control. Below is my control. I was testing with the following new password
    attempt

    mi11ard$

    and it failed with the error message. I copied this from a Microsoft
    example. Can anyone help with this? Thanks.

    <asp:ChangePassword ID="ChangePassword1" runat="server"
    NewPasswordRegularExpression =
    '@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
    NewPasswordRegularExpressionErrorMessage = "Your password must
    be at least 7 characters long, and contain at least one number and one
    special character."
    PasswordHintText = "Please enter a password at least 7
    characters long, containing a number and one special character.">
    </asp:ChangePassword>
    --
    David
     
    DavidC, Sep 13, 2010
    #1
    1. Advertising

  2. DavidC

    Cubaman Guest

    On Sep 13, 10:53 am, "Brian Cryer" <not.here@localhost> wrote:
    > "DavidC" <> wrote in message
    >
    > news:...>I am trying to implement a NewPasswordRegularExpression in a ChangePassword
    > > control.  Below is my control.  I was testing with the following new
    > > password
    > > attempt

    >
    > > mi11ard$

    >
    > > and it failed with the error message. I copied this from a Microsoft
    > > example. Can anyone help with this?  Thanks.

    >
    > <snip>
    >
    > I've tried this usinghttp://regex.cryer.info(an online regular expression
    > tester) and I agree that your pattern doesn't match.
    >
    > But I think the problem is with your pattern:
    >
    > '@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
    >
    > its the @\" at the front which looks wrong, as this is saying that your
    > string (password in your case) must start with @" and indeed @"mi11ard$ does
    > match. If you remove the @\" then mi11ard$ it does match, so:
    >
    > '(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
    >
    > but whether its doing what you want is another matter, as I'm not familiar
    > with (?=...) construct.
    >
    > Hope this helps.
    > --
    >  Brian Cryer
    >  http://www.cryer.co.uk/brian


    I think that David copied the wrong string. The "@" is for verbatim
    literal. Regex should be like:

    <asp:ChangePassword ID="ChangePassword1" runat="server"
    NewPasswordRegularExpression =@"\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W)
    {1,})" />.

    Read more about verbatim strings here:
    http://www.c-sharpcorner.com/Upload...terals11262005010742AM/verbatim_literals.aspx

    Best regards.
     
    Cubaman, Sep 14, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand

    Regular Expression help...

    Anand, Jul 9, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,236
    Eric J. Roode
    Jul 9, 2003
  2. Eric B.
    Replies:
    1
    Views:
    435
    Jim Gibson
    Dec 17, 2004
  3. VSK
    Replies:
    2
    Views:
    2,335
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    863
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,997
    vforvikash
    Dec 29, 2008
Loading...

Share This Page