|
-
Jun 22nd, 2006, 05:34 AM
#1
Thread Starter
Hyperactive Member
[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
-
Jun 22nd, 2006, 05:52 AM
#2
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 22nd, 2006, 06:09 AM
#3
Thread Starter
Hyperactive Member
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
-
Jun 22nd, 2006, 06:19 AM
#4
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
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 22nd, 2006, 09:56 AM
#5
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] Word and number filter
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|