Problem with Regex.Split

edgar_ortiz

Active Member
Licensed User
Longtime User
I have a message containing "records", each "record" has "fields".

Spliting the "records", work fine.

I don't know where is the problem:BangHead:, when I split the "fields"

the problem is that all the fields contain only ONE byte.

Any help is appreciated

B4X:
   Dim lcRecordNum, lcFirstByte, lcLastByte, lcNumBytes As Int
   Dim lcRecords() As String
   Dim lcData As String
   Dim lcWorkData As String
   Dim lcLenWorkData As Int
   '
   pretData.Visible   = False
   prSPData.Visible   = True
   '
   lcRecordNum      = 0
   lcFirstByte      = 0
   lcLastByte      = 0
   lcNumBytes      = 0
   '
   lcWorkData      = WsResultado
   File.WriteString(File.DirRootExternal, "lc_workdata.txt", lcWorkData)
   Log("Len of WorkData : " & lcWorkData.Length)
   '
   lcRecords   = Regex.Split(Chr(194), lcWorkData)
   lcRecordNum   = lcRecords.Length - 1
   Log(lcRecordNum)
   For i = 0 To lcRecordNum
      lcData      = lcRecords(i)
      Log("Registro " & i & ":" & lcData)
      prSPData.Add(lcData)
      '
      Log("First Position: " & lcData.IndexOf("|"))
      Log("Last Position: " & lcData.LastIndexOf("|"))
      '
      Dim lcFields() As String
      lcFields = Regex.Split("|", lcData)
      '
      For x = 0 To lcFields.Length - 1
         Log("Field [" & x & "] :" & lcFields(x) )
      Next
   Next


Thanks in advance

Edgar
 

Attachments

  • Data.txt
    2.2 KB · Views: 171
Last edited:
Top