|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
regular expression problemHi,
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 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. > kieran wrote:
<snip> > I want to create a regular expression on a web form that allows the <snip>> user to input a maximum of 7 characters (these characters can be either > letters or numbers) but no full stops. 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 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.
combobox gives unexpected cast error
Redrawing graphics in userControl - Button Get Icon from CallingAssembly (or ...) Don't understand this warning message ListView iteration order window application refresh every minute Scrolling columns in datagrid Splash Screens and Windows 2000 Re: Listview selected item ToolTip |
|||||||||||||||||||||||