B4J Question How to implement the MidExtract function of B4A in B4J

fhersof

Member
Hello everyone, I am looking for help to use this function in B4J.

Method_636.png
MidExtract (StringText As String, Start As String, EndAt As String) As String

Used to extract text from a string between to other blocks of text.

Ans = MidExtract("Dr. Jim Joe Brown", "Jim", "Brown") 'Returns: Joe

Ans = MidExtract("Dr. Jim [Joe] Brown", "[", "]") 'Returns: Joe

any help is important to me, thank you.
Note. I clarify that in the JStringFunctions library this function is not.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Don't use StringFunctions or jStringFunctions. Old, unmaintained and not needed.

B4X:
Sub AppStart (Args() As String)
    Log(MidExtract("Dr. Jim Joe Brown", "Jim", "Brown").Trim)
    Log(MidExtract("Dr. Jim [Joe] Brown", "[", "]"))
End Sub

 Public Sub MidExtract (StringText As String, Start As String, EndAt As String) As String
     Dim i1 As Int = StringText.IndexOf(Start) + Start.Length
    Dim i2 As Int = StringText.IndexOf2(EndAt, i1)
    Return StringText.SubString2(i1, i2)
End Sub
 
Upvote 0
Top