Android Question How To Correctly Format Split

SpinBower

Member
Licensed User
Longtime User
Hi I have a file that has been turned into a list. The list looks like this:

"[Username=someuser , Password=somepass , lostmode=off , Latitude= , Longitude= , TTS= , Vibrate= , Alarm= , Call= , SMSNumber= , SMSMessage= , POPMessage= , Camera= , Record= , Shutdown= , Restart= , Lockout=off , Screen= , Date= , Wipe= , LockPasscode= ]"

How can I format "FD = Regex.Split(", =", User)" to split on every comma and equal sign?
What I want it to do is just show the username and thats it. "someuser"
Every reply is appriciated!

What I have:
This code just displays: "someuser, Password"

B4X:
Sub Service_Start (StartingIntent As Intent)
If ListData1.IsInitialized Then
ListData1.Add(File.ReadList(File.DirInternal, "userdata.txt"))
User = ListData1.Get(0)
FD = Regex.Split("[,\s]+", User)
FD = Regex.Split("=", User)
ListData2.Initialize2(FD)
Log(ListData2)
ToastMessageShow(ListData2.Get(1), True)
CheckLostMode
Else
ListData1.Initialize
ListData1.Add(File.ReadList(File.DirInternal, "userdata.txt"))
User = ListData1.Get(0)
FD = Regex.Split("[,\s]+", User)
FD = Regex.Split("=", User)
ListData2.Initialize2(FD)
Log(ListData2)
ToastMessageShow(ListData2.Get(1), True)
CheckLostMode
End If
End Sub
 

margret

Well-Known Member
Licensed User
Longtime User
This code will work:

B4X:
Dim a = "[Username=someuser , Password=somepass , lostmode=off , Latitude= , Longitude= , TTS= , Vibrate= , Alarm= , Call= , SMSNumber= , SMSMessage= , POPMessage= , Camera= , Record= , Shutdown= , Restart= , Lockout=off , Screen= , Date= , Wipe= , LockPasscode=bill ]" As String
Dim b() As String
b = Regex.Split(" ,", a)
For i = 1 To b.Length -1
     b(i) = b(i).SubString(b(i).IndexOf("=")+1)
     If i = b.Length -1Then b(i) = b(i).SubString2(0, b(i).Length -1)
     Log(b(i))
Next
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
This code will work:

B4X:
Dim a = "[Username=someuser , Password=somepass , lostmode=off , Latitude= , Longitude= , TTS= , Vibrate= , Alarm= , Call= , SMSNumber= , SMSMessage= , POPMessage= , Camera= , Record= , Shutdown= , Restart= , Lockout=off , Screen= , Date= , Wipe= , LockPasscode=bill ]" As String
Dim b() As String
b = Regex.Split(" ,", a)
For i = 1 To b.Length -1
     b(i) = b(i).SubString(b(i).IndexOf("=")+1)
     If i = b.Length -1Then b(i) = b(i).SubString2(0, b(i).Length -1)
     Log(b(i))
Next

Thanks
 
Last edited:
Upvote 0
Top