[RESOLVED] [2005] Word and number filter
hello,
I am trying to filter 2 things:
1) a username, if the username contains two numbers at the begining of the username then do something
2) look at a string of text if the text contains certain words then do something
I have had a search around and have found filters but they replace the words, if anyone can offer any help that would be great
many thanks
Re: [2005] Word and number filter
To validate username:
VB Code:
Private Function ValidUserName(ByVal UserName As String) As Boolean
Dim reg As New System.Text.RegularExpressions.Regex("\d{2}\w+")
Dim M As System.Text.RegularExpressions.Match = reg.Match(UserName)
Return M.Success
End Function
To look for a specific string
VB Code:
If text.IndexOf("SearchString") <> -1 Then
Re: [2005] Word and number filter
thanks ComputerJy
for the username part, if I wanted to add a msgbox saying username valid if where would I place it.
thanks
Re: [2005] Word and number filter
VB Code:
Private Sub UserNameEntered(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If ValidUserName(UserNameTextBox.Text) Then
MessageBox.Show("Valid Username")
End If
End Sub
Re: [RESOLVED] [2005] Word and number filter