DIYMicha Member Sep 19, 2020 #1 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: Sep 19, 2020
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
Erel B4X founder Staff member Licensed User Longtime User Sep 19, 2020 #2 Don't use this library. It is not needed and not maintained for many years now. The built-in string methods include everything you need.
Don't use this library. It is not needed and not maintained for many years now. The built-in string methods include everything you need.
Jorge M A Well-Known Member Licensed User Longtime User Sep 19, 2020 #3 DIYMicha said: why isn't this function called .Replace like in other dialects? Click to expand... String B4A - Core 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. Click to expand...
DIYMicha said: why isn't this function called .Replace like in other dialects? Click to expand... String B4A - Core 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. Click to expand...