Android Question Get values from String

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I have a string that I need to be able to get values from.

My string looks like this:
Demo 555: Item01=01,Item02=09,Item03=44,TEST01=1234,TEST02=12345, complete

I need a way to some how get the items in red above into it's own string like below, but I am not sure how to do it.

B4X:
Dim demo As String
Dim item01 As String
Dim item02 As String
Dim item03 As String
Dim test01 As String
Dim test02 As String

Anyone able to suggest a way in getting the values in red from my string?
(each value in red might be different in length)
 

Mahares

Expert
Licensed User
Longtime User
NJDude's method is probably more efficient, but I was writing mine while he was posting his. So I thought I give you another way, for what it is worth:
B4X:
Dim MyString As String
MyString="Demo 555: Item01=01,Item02=09,Item03=44,TEST01=1234,TEST02=12345, complete"
MyString=MyString.SubString(MyString.IndexOf(":")+2).Replace(", complete","")
Dim MyStringArray() As String
MyStringArray=Regex.Split(",", MyString)
For i=0 To MyStringArray.Length-1
   MyStringArray(i)=MyStringArray(i).SubString(MyStringArray(i).IndexOf("=")+1)
  Msgbox(MyStringArray(i), "")    'displays 01, 09. 44, 1234, 12345    one by one
Next
 
Upvote 0
Top