I am using the subroutine below to insert (bold) tags {b} into a multi-line string that I later format with a rich string formatter. The pattern is based upon selecting everything on a new line as far as a colon ':' character.
At the moment it works perfectly until it encounters a string that contains more than one instance of the pattern on different lines... then it ignores them both and skips the tags. What have I misunderstood here?
At the moment it works perfectly until it encounters a string that contains more than one instance of the pattern on different lines... then it ignores them both and skips the tags. What have I misunderstood here?
B4X:
Sub InsertBoldTags(Subject As String) As String
Dim Pattern As String
Dim Matcher1 As Matcher
Pattern = "^.+:"
Matcher1 = Regex.Matcher2(Pattern, Regex.MULTILINE , Subject)
Do While Matcher1.Find
Subject = Subject.Replace(Matcher1.Match,"{b}" & Matcher1.Match & "{b}")
Loop
Return Subject
End Sub