tufanv Expert Licensed User Longtime User Feb 8, 2017 #1 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: Feb 8, 2017
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
S sorex Expert Licensed User Longtime User Feb 8, 2017 #3 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
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))
Erel B4X founder Staff member Licensed User Longtime User Feb 8, 2017 #4 \s+ is better as it will handle TAB characters as well. Last edited: Feb 8, 2017 Upvote 0
S sorex Expert Licensed User Longtime User Feb 8, 2017 #5 Indeed, I was not aware that regex.split supported the regex matching operators. Upvote 0