Sub Activity_Create(FirstTime As Boolean)
Dim s As String = "$number1#number2*"
Dim m As Matcher = Regex.Matcher("\$([^#]+)#([^*]+)\*", s)
If m.Find Then
Log(m.Group(1))
Log(m.Group(2))
End If
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim s As String = "$number1#number2*"
Dim m As Matcher = Regex.Matcher("\$([^#]+)#([^*]+)\*", s)
If m.Find Then
Log(m.Group(1))
Log(m.Group(2))
End If
End Sub
Regular expressions look awfully complicated until you look close enough...
B4X:
"\$([^#]+)#([^*]+)\*"
I will explain the pattern here:
- $ is a special character so we need to "escape" it -> \$
- Then we want to catch all characters that are not # -> ([^#]+) note that the parenthesis define a group (group number 1).
- The # character.
- All characters that are not * -> ([^*]+) note that we do not need to escape special characters in a negation class.
- The * character.
Regular expressions look awfully complicated until you look close enough...
B4X:
"\$([^#]+)#([^*]+)\*"
I will explain the pattern here:
- $ is a special character so we need to "escape" it -> \$
- Then we want to catch all characters that are not # -> ([^#]+) note that the parenthesis define a group (group number 1).
- The # character.
- All characters that are not * -> ([^*]+) note that we do not need to escape special characters in a negation class.
- The * character.
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Serial1.Initialize("Serial1")
Timer1.Initialize("Timer1", 200)
End If
End Sub
Sub
Timer1_Tick
Dim s As String
Dim m As Matcher
s = TextReader1.ReadLine
txtLog.Text = s
m = Regex.Matcher("\$([^#]+)#([^*]+)\*", s)
If m.Find Then
Label1.Text=(m.Group(1))
Label2.Text=(m.Group(2))
End If
End Sub
Ok. Now I put timer to 400 and it is ok.
But just one question please.
When i minimize application, after maybe 30 seconds or 1 minute I go back to application, numbers are late. i Think the problem is with buffer?