iOS Question Regex Replace For iOS

RichardN

Well-Known Member
Licensed User
Longtime User
This was extremely useful to replace ALL instances of a certain Regex pattern in B4A.

B4X:
Sub RegexReplace(Pattern As String, Text As String, Replacement As String) As String
  
    Dim m As Matcher
    m = Regex.Matcher2(Pattern, Regex.MULTILINE, Text)
    Dim jo As JavaObject = m
    Return jo.RunMethod("replaceAll", Array(Replacement))
 
End Sub

How can it be translated for B4i ?
 

RichardN

Well-Known Member
Licensed User
Longtime User
Thanks JanPRO. Amazed to find a topic that is simpler in B4i than in B4A.

The code above can be replaced by:

Text = Regex.Replace2("^(.+)\:", Regex.MULTILINE, Text, "\{b}$1\:{b}") 'Add embolden tags where desired
 
Upvote 0
Top