Home All Groups Group Topic Archive Search About

regular expression problem

Author
10 Jul 2006 4:28 PM
kieran
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.

Author
10 Jul 2006 6:36 PM
Samuel Shulman
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

Show quoteHide quote
"kieran" <kieran5***@hotmail.com> wrote in message
news:1152548908.721896.210940@75g2000cwc.googlegroups.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.
>
Author
11 Jul 2006 12:35 AM
Branco Medeiros
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(ByVal Text As String) As Boolean
    Return System.Text.RegularExpressions.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.
Author
11 Jul 2006 1:22 PM
kieran
cheers Branco...




Branco Medeiros wrote:

Show quoteHide quote
> 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(ByVal Text As String) As Boolean
>     Return System.Text.RegularExpressions.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.