iOS Question Regex Replace For iOS

Discussion in 'iOS Questions' started by RichardN, Sep 19, 2015.

  1. RichardN

    RichardN Active Member Licensed User

    This was extremely useful to replace ALL instances of a certain Regex pattern in B4A.

    Code:
    Sub RegexReplace(Pattern As String, Text As String, Replacement As StringAs 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 ?
     
  2. JanPRO

    JanPRO Well-Known Member Licensed User

  3. RichardN

    RichardN Active Member Licensed 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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Actually I think that B4i is simpler than B4A (because of the differences between the platforms).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice