[RESOLVED] select text between Strings
Is there a string function in VB.net which lets you select text between Strings?? For example:
str1 = "This boy's name is Mike, and he likes to play soccer. Mike also likes to play basketball. This boy's name is John, and he likes to play Hockey. John also likes to play football."
I need to select out the names, and the 2 sports they each like to play....
Now, I've tried using str1.IndexOf() with str1.Substring(), but it wasn't very accurate. Has anyone come across something similar??
Thanks.
Re: select text between Strings
Something like this should work.
VB Code:
Imports System.Text.RegularExpressions
...
For Each mt as Match in Regex.Matches(str1,"This boy's name is (\w+), and he likes to play (\w+). (\w+) also likes to play (\w+).")
'mt.Groups(1).tostring = first Mike
'mt.Groups(2).tostring = soccer
'mt.groups(3).tostring = second Mike
'mt.groups(4).tostring = basketball
Next
Re: select text between Strings
Thanks wild_bill!
Works great!!