Dim cs As CSBuilder
cs.Initialize
cs.Alignment("ALIGN_RIGHT")
cs = Miniature.MarkPatternCSbuilder(lbldesc,cs,lbldesc.Text,1)
lbldesc.AttributedText = cs.PopAll
Sub MarkPatternCSbuilder(Textview2 As TextView,CS As CSBuilder,Input As String, GroupNumber As Int) As CSBuilder
Pattern = "((([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,])+)|(http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,\s]*)?))"
Dim lastMatchEnd As Int = 0
Dim m As Matcher = Regex.Matcher(Pattern, Input)
Do While m.Find
Dim currentStart As Int = m.GetStart(GroupNumber)
Dim temp As String
temp = Input.SubString2(lastMatchEnd, currentStart)
CS.Append(temp)
lastMatchEnd = m.GetEnd(GroupNumber)
Dim temp As String
temp = m.Group(GroupNumber)
If Regex.IsMatch("(http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?)",temp) Then
CS.Color(Colors.RGB(91,35,179))
CS.Alignment("ALIGN_LEFT")
CS.Link(temp)
CS.Append(temp)
CS.Pop.Pop
Else If Regex.IsMatch("([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,\s])+",temp) Then
CS.Color(Textview2.TextColor)
CS.Font(Textview2.Font)
CS.Alignment("ALIGN_LEFT")
CS.Append(temp)
CS.Pop.Pop
Else
CS.Color(Textview2.TextColor)
CS.Font(Textview2.Font)
CS.Alignment("ALIGN_RIGHT")
CS.Append(temp)
CS.Pop.Pop
End If
Loop
If lastMatchEnd < Input.Length Then
CS.Font(Textview2.Font)
CS.Append(Input.SubString(lastMatchEnd)).Pop
End If
Return CS
End Sub