Android Question Regex.Split Does not appear to work with high bit characters

MrKim

Well-Known Member
Licensed User
Longtime User
So probably the other functions as well. Can anybody confirm this?

For safety I was going to use ASCII above 128 to divide my data but it dosn't seem to work.

Can anyone confirm this?

Is this true of Android in general or B4A in general - High bit characters are not supported?

The other day I also noticed split also failed when using ][ as part of a divider.

Thanks
Kim
 

Mahares

Expert
Licensed User
Longtime User
You will have to escape the ][:
B4X:
MyString=Regex.Split("\]\[",MyText)  'need the \slash to escape it as ][ is a special character
But your best bet is to do it like this:

B4X:
Dim MyText As String="[New York][Cairo][Zurich]".Replace("[","")
Dim MyString() As String
MyString=Regex.Split("]",MyText)
Msgbox( MyString(0) & " " & MyString(1) & " " & MyString(2),"") 'displays New York Cairo Zurich
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I was actually using multiple characters as a separator for fields so I just changed the characters. :)
My real question comes with high bit characters (> ASCII 128) I would prefer to use them, but they do not seem to work at all.
I wonder if they can be escaped? Hmmmm. I will test that when I have time.

Also, Is there a list of the special characters that need to be escaped. I VBA/Access I more or less know this stuff by heart.

I was just looking at your code again - are you saying '][' is the special character but '[' and ']' separately are not?
 
Last edited:
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Turns out the issue is not with Regex but with File.Readstring and file.ReadText. The are evidently making assumptions about encoding and scrambling my data. I will stick with longer for safety low bit separators unless there is an easy way to read in the binary data.
 
Upvote 0
Top