B4X:
Dim components() As String
components = Regex.Split("", "1234")
B4A: 5 strings - "" "1" "2" "3" "4"
B4J: 4 strings - "1" "2" "3" "4"
https://www.b4x.com/android/forum/threads/regex-split.157791/
Dim components() As String
components = Regex.Split("", "1234")
Source: https://stackoverflow.com/q/38513563 (see the comments)This is the expected behavior for String#split for Java version up to 7 and has been changed in Java 8: Why in Java 8 split sometimes removes empty strings at start of result array?
– Tom
Jul 21, 2016 at 20:44
- @HoangHuynh you may use JDK 6 or above for Android development. However, the compilation supports Java version 6 (and 7 in case of KitKat). I think what the OP meant is also for java version (not JDK)
– waqaslam
Apr 27, 2014 at 1:01- 13
Java 8 is OFFICIALLY supported in Android N. android-developers.blogspot.com/2016/03/…
– Jason
Mar 9, 2016 at 18:45Source: https://stackoverflow.com/q/38513563 (see the comments)
You never quit Mario. I quickly tested and it shows 4 elements in B4AB4A: 5 strings - "" "1" "2" "3" "4"
Dim components() As String
components = Regex.Split("", "1234")
Log(components.Length)
For i =0 To components.Length-1
Log(components(i))
Next
That's exactly what I was writing:Where Regex come from?
Is it included in Java JDK?
Could it be something related to the Java version?
@LucaMs which version of Java do you have in your path?
I tested with Open JDK 14 and 17.
Is it possible that even when I compile with jdk 14 javac.exe other jdk 8 files are used? But if that were the case, why doesn't the same thing happen with B4J?Just now I created a new "default" project, compiled with jdk 14.0.1 (javac.exe, of course): 5 strings!
Yes, Android 8, but the question was asked by another Italian member, who most likely has a more recent Android.Are you doing this on a real device? What Android version?