B4J Question Regex array problem

maleche

Active Member
Licensed User
Longtime User
Folks,
please forgive me. i'm not on my programming laptop so i have to type my code.

I have serial data streaming as a comma delimited packet received from

Sub AStream_NewData(buffer() as Byte)
Dim s as String = BytesToString(Buffer,0,Buffer.Length,"UTF8")
ParseValues(s)
End Sub

12,34
44,22
0,46
54,22
56,67
etc...
When the serial data arrives, i send it to a parser:

Sub parseValues(str as String)
Log("DataIn:" & str) <-----------WORKS! shows 12,34
Dim s() as string
Dim leftValue as long
Dim rightValue as long
s=Regex.Split(",",str)
Log("Left:" & s(0) & " Right:" & s(1)) <-----------WORKS! displays correctly!
leftValue = s(0)<-------------WORKS!
rightValue=s(1) <------------this always fails! java.lan.NumberFormatException: For input String: "12 34"
end sub

any help is greatly appreciated!
Thank you in advance!
Doyle
 
Last edited:

maleche

Active Member
Licensed User
Longtime User
Didier9,
you are correct!
in fact, i discovered three and removed them.
Thank you sir!
 
Upvote 0
Top