How do I "extract" the "touchphotogrey.png" from the "MyGetFrom" string?
I have tried:
B4X:
Dim MyGetFrom As String = rxHW.Get(10)
Dim ANS As List
ANS = sf.split(MyGetFrom, ".")
Log("My List: " & ANS)
Dim ANSINT As Int
ANSINT = ANS.Size
Dim MyFileName As String = ANS(ANSINT -1)
Yes, I have seen that we can not split by "dot". Another solution could be to replace dots by "/" and then split by "/" and get the last two items
B4X:
Sub GetFileName (myURL as String) as String
'Dim myURL As String = "https://api.appery.io/rest/1/db/files/58870186e4b07690b0043107/2003060e-5b47-440a-95ba-507b43de2c14.touchphotogrey.png"
Dim SF As StringFunctions
SF.Initialize
Dim L0 As List
L0.Initialize
myURL=myURL.Replace(".","/")
L0=SF.Split(myURL,"/")
If L0.Size > 2 Then
Return $"${L0.Get(L0.Size-2)}.${L0.Get(L0.Size-1)}"$
End If
End Sub
Dim data As String
data = "touchphotogrey.png"
Dim values() As String
values = Regex.Split("\.", data) ' Or was it /.?
Dim l As List
l.Initialize2(values)
Log(l)
Dim MyGetFrom As String = "https://api.appery.io/rest/1/db/files/58870186e4b07690b0043107/2003060e-5b47-440a-95ba-507b43de2c14.touchphotogrey.png"
Dim values() As String = Regex.Split("\.", MyGetFrom)
Dim MyFileName As String =values(values.Length -2) & "." & values(values.Length -1)
Log(MyFileName) 'displays: touchphotogrey.png