Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Regular expression help

Reply
Thread Tools

Regular expression help

 
 
DavidC
Guest
Posts: n/a
 
      09-12-2010
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
 
Reply With Quote
 
 
 
 
Cubaman
Guest
Posts: n/a
 
      09-14-2010
On Sep 13, 10:53*am, "Brian Cryer" <not.here@localhost> wrote:
> "DavidC" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...>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/UploadF..._literals.aspx

Best regards.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seek xpath expression where an attribute name is a regular expression GIMME XML 3 12-29-2008 03:11 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments