regular expression problem

  • Thread starter Thread starter kieran
  • Start date Start date
K

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.
 
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 wrote:
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.
 
cheers Branco...




Branco said:
kieran wrote:

<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.
 
Back
Top