Code Hint: Regex (Error: java.lang.ArrayIndexOutOfBoundsException )

dbergusa

Member
Licensed User
Longtime User
Dim arr() As String
arr = Regex.Split(".","Hello.World")
Msgbox(arr(0),"Error")

certain delimeters will cause errors in java when using regex if not escaped

resolved by the following

arr = Regex.Split("\.","Hello.World")


Error code = java.lang.ArrayIndexOutOfBoundsException

Noted characters include

. period or dot
+ plus

While this may not be a "bug" as much as it is restricted characters in regex, it is worth noting in case others come across the errors when java balks with the above error.

Admins: feel free to move this to another thread if not appropriate here
 

dbergusa

Member
Licensed User
Longtime User
The issue is that the error does not surface until the apk gets run in java (emulator/device). Thus whatever is happening, B4A overlooks the error and allows it to pass through. The resulting java error is listed for those that may come across it when working with B4A and regular expressions.
 

dbergusa

Member
Licensed User
Longtime User
Not a worry, just an attempt to point others in the right direction when they encounter this. Regex can be implemented very irregularly depending on the language.

B4A is exceptional at helping pinpoint errors, but once it has been handed over to java, it can become less clear as to what happened. Code lines won't match up and error messages are often vague.

Good information on the topic and how b4a handles regex.
 
Top