Android Question Regex.Split Array Problem

Whack

New Member
Hello, I have an array called strPackets() which is a string, and I'm using regex.split to fill the array with different sections of another string (strBuffer) which are separated by Chr(4)

B4X:
strPackets = Regex.Split(Chr(4), strBuffer)

However, after I do this and I try to get the length of an array value, like this, it errors.

B4X:
If strPackets(anyvalidnumberinthearray).Length > 3 Then

What am I doing wrong? I can't get anything from that value but it definitely exists because the regex.split fills strPackets(1) with a string

Thanks in advance
 

sorex

Expert
Licensed User
Longtime User
you need to define the array that regex will split to

B4X:
Dim strPackets() As String
strPackets= Regex.Split(Chr(4), "lklklk lk " & Chr(4) & "lk lk lk" )
Log(strPackets(0).Length)

If strPackets(0).Length > 3 Then
Log("ok")
Else
Log("not ok")
End If

that put this in the log

B4X:
** Activity (main) Create, isFirst = true **


10
ok
** Activity (main) Resume **
 
Upvote 0
Top