E.g.
vb.net Code:
Dim findStartIndex = 0
Dim openingChars = {"<"c, "("c, "{"c, "["c}
Dim closingChars = {">"c, ")"c, "}"c, "]"c}
Do
'Find the start of the next substring.
Dim substringStartIndex = RichTextBox1.Find(openingChars, findStartIndex)
If substringStartIndex = -1 Then
'No more substrings to find.
Exit Do
End If
Dim openingChar = RichTextBox1.Text(substringStartIndex)
Dim closingChar = closingChars(Array.IndexOf(openingChars, openingChar))
'Find the end of the current substring.
Dim substringEndIndex = RichTextBox1.Find({closingChar}, substringStartIndex + 1)
'Use substringStartIndex and substringEndIndex here.
'The next search starts after the current substring.
findStartIndex = substringEndIndex + 1
Loop