LucaMs Expert Licensed User Longtime User Dec 4, 2023 #1 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/
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/
LucaMs Expert Licensed User Longtime User Dec 4, 2023 #21 Solved so: B4X: Dim components() As String ' components = Regex.Split("", "1234") components = Regex.Split("(?<=.)", "1234") Log("Length: " & components.Length) For i = 0 To components.Length - 1 Log("Component " & components(i)) Next But who solved it that way? ChatGPT ? Upvote 0
Solved so: B4X: Dim components() As String ' components = Regex.Split("", "1234") components = Regex.Split("(?<=.)", "1234") Log("Length: " & components.Length) For i = 0 To components.Length - 1 Log("Component " & components(i)) Next But who solved it that way? ChatGPT ?
MarcoRome Expert Licensed User Longtime User Dec 4, 2023 #22 Yes, same code, different behaviors. It depends on the android version. on a device ( all real device ) with: Android 8 I have the 5 values (wrong) Android 11 is fixed Android 13 is fixed Upvote 0
Yes, same code, different behaviors. It depends on the android version. on a device ( all real device ) with: Android 8 I have the 5 values (wrong) Android 11 is fixed Android 13 is fixed
OliverA Expert Licensed User Longtime User Dec 4, 2023 #23 Found the answer on stackoverflow. The behavior when dealing with an empty String pattern has changed between Java 7 and Java 8. Depending on the version of Android, you may be dealing with Java 6, 7 or 8. This has nothing to do with the with the JDK you use in B4A to generate you APK, but with the Java implemented within Android. 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 Click to expand... Source: https://stackoverflow.com/q/38513563 (see the comments) @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:45 Source: https://stackoverflow.com/q/38513563 (see the comments) Click to expand... Click to expand... Upvote 1
Found the answer on stackoverflow. The behavior when dealing with an empty String pattern has changed between Java 7 and Java 8. Depending on the version of Android, you may be dealing with Java 6, 7 or 8. This has nothing to do with the with the JDK you use in B4A to generate you APK, but with the Java implemented within Android. 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 Click to expand... Source: https://stackoverflow.com/q/38513563 (see the comments) @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:45 Source: https://stackoverflow.com/q/38513563 (see the comments) Click to expand... Click to expand...