Split String into Tabular Form

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have an text below that contains "-" and "|"

"-" ----> Split as Column delimeter
"|"-----> Split as Row delimeter

TA171/07-2046-1100-2046|TA172/02-890-890-890|TA174/04-930-930-930|TA174/05-461-461-461|TA177/02-521-521-521|TA178/02-1701-1701-1701|TA179/01-2866-221-2866|.

I want to display as Tabular form using this text.Please advise how to do that and send me a sample code to solve this problem.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code will create a List of rows. Each item in the list is an array with the values of this row:
B4X:
    Dim s As String
    s = "TA171/07-2046-1100-2046|TA172/02-890-890-890|TA174/04-930-930-930|TA174/05-461-461-461|TA177/02-521-521-521|TA178/02-1701-1701-1701|TA179/01-2866-221-2866|"
    Dim Rows() As String
    Rows = Regex.Split("[|]", s)
    Dim Table As List
    Table.Initialize
    For i = 0 To Rows.Length - 1
        Table.Add(Regex.Split("[-]", Rows(i)))
    Next
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
@junaidahmed
Attached you find a program displaying your data in a table.
The program is based on this TableExample.

@Erel
Is this writing with the brackets somewhere commented Regex.Split("[|]", s) ?
I had tries Regex.Split("|", s) but it splits in all characters "T","A","1"...

Regex.Split("[-]", s) and Regex.Split("-", s) both work.

Are the brackets needed for 'special' characters ?

Best regards.
 

Attachments

  • TableExampleTable.zip
    12.6 KB · Views: 303
Last edited:
Upvote 0
Top