Using Regular Expression Validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Coleen

    Using Regular Expression Validation

    I can't remember the correct way to write a custom regular expression validator, and the help file for VB.net is not terribly helpful...it does not give any real world examples. I've got the main syntax of ^[a-zA-z] but I can't remember how to write the next portion. I need to validate passwords...the y must start with a letter of the alphabet, can contain 0-9 and can contain the special characters @#$%&, I just can't remember the correct syntax to write this as a regular expression validation.
    Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special characters, they can be in any order as long as the first character is a letter.

    Any help/suggestions are greatly appreciated.

    TIA, Coleen

    ---
    Posted using Wimdows.net NntpNews Component -

    Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
  • Peter Blum

    #2
    Re: Using Regular Expression Validation

    That looks very good for someone who cannot remember Regexes :)

    Here's a resource I like for figuring out regexes:


    The only question I would have is whether you have a minimum size. In that
    case, replace the ? with a {min, max} like {4, 20}.

    Also add the '$' to the end.

    --- Peter Blum

    Email: PLBlum@PeterBlu m.com
    Creator of "Profession al Validation And More" at


    <Coleen> wrote in message news:u7mee5%23I EHA.1192@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > I can't remember the correct way to write a custom regular expression[/color]
    validator, and the help file for VB.net is not terribly helpful...it does
    not give any real world examples. I've got the main syntax of ^[a-zA-z] but
    I can't remember how to write the next portion. I need to validate
    passwords...the y must start with a letter of the alphabet, can contain 0-9
    and can contain the special characters @#$%&, I just can't remember the
    correct syntax to write this as a regular expression validation.[color=blue]
    > Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special[/color]
    characters, they can be in any order as long as the first character is a
    letter.[color=blue]
    >
    > Any help/suggestions are greatly appreciated.
    >
    > TIA, Coleen
    >
    > ---
    > Posted using Wimdows.net NntpNews Component -
    >
    > Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup[/color]
    engine supports Post Alerts, Ratings, and Searching.


    Comment

    • Coleen

      #3
      Re: Using Regular Expression Validation

      Thanks :-) I took it in class, but it's been months since I've used it, so
      I'm not certain it will do everything I need. I do need to check it for
      length, thanks very much for the suggestion and link. I appreciate it :-)
      "Peter Blum" <PLBlum@Blum.in fo> wrote in message
      news:eBtsflMJEH A.1224@TK2MSFTN GP11.phx.gbl...[color=blue]
      > That looks very good for someone who cannot remember Regexes :)
      >
      > Here's a resource I like for figuring out regexes:
      >[/color]
      http://devedge.netscape.com/library/...p.html#1193136[color=blue]
      >
      > The only question I would have is whether you have a minimum size. In that
      > case, replace the ? with a {min, max} like {4, 20}.
      >
      > Also add the '$' to the end.
      >
      > --- Peter Blum
      > www.PeterBlum.com
      > Email: PLBlum@PeterBlu m.com
      > Creator of "Profession al Validation And More" at
      > http://www.peterblum.com/vam/home.aspx
      >
      > <Coleen> wrote in message news:u7mee5%23I EHA.1192@TK2MSF TNGP11.phx.gbl. ..[color=green]
      > > I can't remember the correct way to write a custom regular expression[/color]
      > validator, and the help file for VB.net is not terribly helpful...it does
      > not give any real world examples. I've got the main syntax of ^[a-zA-z][/color]
      but[color=blue]
      > I can't remember how to write the next portion. I need to validate
      > passwords...the y must start with a letter of the alphabet, can contain 0-9
      > and can contain the special characters @#$%&, I just can't remember the
      > correct syntax to write this as a regular expression validation.[color=green]
      > > Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special[/color]
      > characters, they can be in any order as long as the first character is a
      > letter.[color=green]
      > >
      > > Any help/suggestions are greatly appreciated.
      > >
      > > TIA, Coleen
      > >
      > > ---
      > > Posted using Wimdows.net NntpNews Component -
      > >
      > > Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup[/color]
      > engine supports Post Alerts, Ratings, and Searching.
      >
      >[/color]


      Comment

      Working...