Bug? Error when using StringFunctions ".Stuff" function

DIYMicha

Member
When I try to replace a substring that isn't present in the string, the function crashes with out of bounds exception.

But should'nt it just do nothing, and return the original string, like in every other BASIC dialect? And speaking of other dialects, why isn't this function called .Replace like in other dialects? :)

right now I have to combine the .Stuff function with a .InString function to check if the substring is contained...

B4X:
    WikiUrl=InputWiki.Text
        If sf.InString(WikiUrl,".m.")>-1 Then
            WikiUrl = sf.Stuff(WikiUrl,".",".m.")        ' Clean url, replace mobile ".m." to regular desktop url
        End If

Greetings
 
Last edited:

Jorge M A

Well-Known Member
Licensed User
why isn't this function called .Replace like in other dialects?

String
Method_636.png
Replace (Target As String, Replacement As String) As String

Returns a new string resulting from the replacement of all the occurrences of Target with Replacement.
 
Top