Dim s As String = edtDose.Text
Dim cs As CSBuilder = MarkPattern(s, "\B(℗\w+)\b", 1)
edtDose.Text = cs
Dim y As String = edtDose.Text
Dim cs As CSBuilder = MarkRoute(y, "\B:)\w+)\b", 1)
edtDose.Text = cs
Sub MarkPattern(Input As String, Pattern As String, GroupNumber As Int) As CSBuilder
Dim cs As CSBuilder
cs.Initialize
Dim lastMatchEnd As Int = 0
Dim m As Matcher = Regex.Matcher(Pattern, Input)
Do While m.Find
Dim currentStart As Int = m.GetStart(GroupNumber)
Log(GroupNumber)
Log(currentStart)
cs.Append(Input.SubString2(lastMatchEnd, currentStart))
Dim AA As String = Input.SubString2(lastMatchEnd, currentStart)
Log(AA)
lastMatchEnd = m.GetEnd(GroupNumber)
Log(lastMatchEnd)
'cs.Bold.Underline
cs.Underline
'cs.Color(0xFFEE82EE)
cs.Color(0xFF4169E1)
cs.Clickable("cs", m.Group(GroupNumber))
cs.Append(m.Group(GroupNumber))
'cs.Pop.Pop.Pop.Pop 'number should match number of stylings set.
cs.Pop.Pop.Pop
Loop
If lastMatchEnd < Input.Length Then cs.Append(Input.SubString(lastMatchEnd))
Return cs
End Sub
Sub MarkRoute(Input As String, Pattern As String, GroupNumber As Int) As CSBuilder
Dim cs As CSBuilder
cs.Initialize
Dim lastMatchEnd As Int = 0
Dim m As Matcher = Regex.Matcher(Pattern, Input)
Do While m.Find
Dim currentStart As Int = m.GetStart(GroupNumber)
Log(GroupNumber)
Log(currentStart)
cs.Append(Input.SubString2(lastMatchEnd, currentStart))
Dim AA As String = Input.SubString2(lastMatchEnd, currentStart)
Log(AA)
lastMatchEnd = m.GetEnd(GroupNumber)
Log(lastMatchEnd)
'apply styling here
cs.Underline
'cs.Color(0xFF6B8E23)
cs.Color(0xFFD1650B)
cs.Clickable("cs", m.Group(GroupNumber))
cs.Append(m.Group(GroupNumber))
cs.Pop.Pop.Pop 'number should match number of stylings set.
Loop
If lastMatchEnd < Input.Length Then cs.Append(Input.SubString(lastMatchEnd))
Return cs
End Sub