B4J Question split a textarea line into words

tufanv

Expert
Licensed User
Longtime User
Hello

I am using :

B4X:
    Dim Lines() As String = Regex.Split(CRLF,TextArea1.text)


        Log(Lines(0))

to get any line from the textarea successfully. Every line is similar to :

B4X:
DATA1    3    1,07832    1,08822    1,09842    17:15:41

Is it possible to also split every line to these 6 data and easliy get the line(0)'s 4th data for example which is : 1,08822 ?

If it is possible with regex can you give an example please ?

I tried to use :

B4X:
Dim words() As String = Regex.split(" +",Lines(0))

but no luck, it tales whole line as one word.

Thanks
 
Last edited:

sorex

Expert
Licensed User
Longtime User
In such case of space alignments I usually do it like this

B4X:
Dim data() As String
Dim MyString As String="DATA1    3    1,07832    1,08822    1,09842    17:15:41"
data=Regex.Split(" ",MyString.Replace("  "," "))
Log(data(4))
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Indeed, I was not aware that regex.split supported the regex matching operators.
 
Upvote 0
Top