regular expression problem

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

    #1

    regular expression problem


    Hi,

    I want to create a regular expression on a web form that allows the
    user to input a maximum of 7 characters (these characters can be either
    letters or numbers) but no full stops.

    I cant seem to get this right.

    Any input or simple regular expression tutorials appreciated.

    Thanks.

  • Samuel Shulman

    #2
    Re: regular expression problem

    I think that you can use the text_changed event (that will be server side
    processing)

    btw, this is VB group not ASP

    hth,
    Samuel Shulman

    "kieran" <kieran5405@hot mail.comwrote in message
    news:1152548908 .721896.210940@ 75g2000cwc.goog legroups.com...
    >
    Hi,
    >
    I want to create a regular expression on a web form that allows the
    user to input a maximum of 7 characters (these characters can be either
    letters or numbers) but no full stops.
    >
    I cant seem to get this right.
    >
    Any input or simple regular expression tutorials appreciated.
    >
    Thanks.
    >

    Comment

    • Branco Medeiros

      #3
      Re: regular expression problem

      kieran wrote:
      <snip>
      I want to create a regular expression on a web form that allows the
      user to input a maximum of 7 characters (these characters can be either
      letters or numbers) but no full stops.
      <snip>

      Regardless of where and how you'd use the regex, I guess you can use
      the following, which will match 1 up to seven alphanumeric chars:

      Function IsValidInput(By Val Text As String) As Boolean
      Return System.Text.Reg ularExpressions .Regex.IsMatch( _
      Text, "^(\w|\d){1,7}$ " _
      )
      End Function

      The regex above will match the whole string (the "^" requires that the
      match begins at the begining of the string, and the "$" requires that
      the match ends at the end of the string). It will match 1 to 7
      occurrences (the "{1, 7}" operator) of letters ("\w") or digits ("\d").

      HTH.

      Regards,

      Branco.

      Comment

      • kieran

        #4
        Re: regular expression problem


        cheers Branco...




        Branco Medeiros wrote:
        kieran wrote:
        <snip>
        I want to create a regular expression on a web form that allows the
        user to input a maximum of 7 characters (these characters can be either
        letters or numbers) but no full stops.
        <snip>
        >
        Regardless of where and how you'd use the regex, I guess you can use
        the following, which will match 1 up to seven alphanumeric chars:
        >
        Function IsValidInput(By Val Text As String) As Boolean
        Return System.Text.Reg ularExpressions .Regex.IsMatch( _
        Text, "^(\w|\d){1,7}$ " _
        )
        End Function
        >
        The regex above will match the whole string (the "^" requires that the
        match begins at the begining of the string, and the "$" requires that
        the match ends at the end of the string). It will match 1 to 7
        occurrences (the "{1, 7}" operator) of letters ("\w") or digits ("\d").
        >
        HTH.
        >
        Regards,
        >
        Branco.

        Comment

        Working...