vaultworld
asked on
Is Regex the best way to do simple pattern matching in VB?
Is Regex the best way to do simple pattern matching in VB.NET.
Here I'm check in the string has the word News in it.
Dim objMatch As Match
objMatch = Regex.Match("News", sSave.ToString)
If (objMatch.Success) Then
' sSave = "Got News"
End If
Here I'm check in the string has the word News in it.
Dim objMatch As Match
objMatch = Regex.Match("News", sSave.ToString)
If (objMatch.Success) Then
' sSave = "Got News"
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IndexOf is the way to go if you are looking for a simple string within another string. Don't get RegEx unless you are looking for more complex patterns (like multiple strings separated by any number of characters, patterns, etc).
ASKER
Thanks a ton, both of you
ASKER
If the string is the same size that your looking for it doesn't work.
Example looks for News inside of News