SPLIT THE STRING ARRAY WITH RESPECT TO CHARACTER (showing inappropriate resuilts) Expectation - (split wrt ":61:") Reality - (spliting wrt ":" or\and wrt "6" or/and wrt "1" or/and wrt "61" etc)

Hi Team,

So I was working on the string manipulation part, where I wanted to split the string(basically the input text file which has multiple instances of some character)

Eg:- INput text file contains to following:-

:20:AIM0013063240001
:25:088000001011
:28C:00170/00001
:60F:C140903CNY0,00
:61:1409030903CY12,40NTRFNONREF//NONREF
LP4140902YLP70000006
:86:/OR/LP4140903YLP70000006
/ORDP/付款方名称付款方名称付款方
名称付款方名称付款方名称付款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明
/VA/0000000001
:61:1409030903DY4,50NTRFCUSTREF0001//3764438307060001
140903YLP17026351
:86:/OR/140903YLP17026351
/AC/12345678901234567890
/BENM/收款方名称收款方名称收款方
名称收款方名称收款方名称收款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明
:61:1409030903DY5,50NCHGCUSTREF0001//3764438307060001
140903YLP17026351
:86:/OR/140903YLP17026351
/AC/12345678901234567890
PAYMENT CHARGES
/BENM/收款方名称收款方名称收款方
名称收款方名称收款方名称收款方名
:61:1409030903DY2,40NCHGCUSTREF0002//2625153196060001
140903PO130024653
:86:/OR/140903PO130024653
AUTOPAY OUT CHARGES
:62F:C140903CNY0,00
:64:C140903CNY0,00
:86:/OSDR/HSBCCNSH

Now I want to split the string with respect to “:61:”, such that I get the charArray such that:-

StringArray(0) =
:20:AIM0013063240001
:25:088000001011
:28C:00170/00001
:60F:C140903CNY0,00

StringArray(1)=
:61:1409030903CY12,40NTRFNONREF//NONREF
LP4140902YLP70000006
:86:/OR/LP4140903YLP70000006
/ORDP/付款方名称付款方名称付款方
名称付款方名称付款方名称付款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明
/VA/0000000001

StringArray(2)=
:61:1409030903DY4,50NTRFCUSTREF0001//3764438307060001
140903YLP17026351
:86:/OR/140903YLP17026351
/AC/12345678901234567890
/BENM/收款方名称收款方名称收款方
名称收款方名称收款方名称收款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明

StringArray(3)=
:61:1409030903DY5,50NCHGCUSTREF0001//3764438307060001
140903YLP17026351
:86:/OR/140903YLP17026351
/AC/12345678901234567890
PAYMENT CHARGES
/BENM/收款方名称收款方名称收款方
名称收款方名称收款方名称收款方名

StringArray(4)=
:61:1409030903DY2,40NCHGCUSTREF0002//2625153196060001
140903PO130024653
:86:/OR/140903PO130024653
AUTOPAY OUT CHARGES
:62F:C140903CNY0,00
:64:C140903CNY0,00
:86:/OSDR/HSBCCNSH

I hope you get my point.

WHAT I HAVE tried=

  1. Read Text File activity (file path given) -> String strInputText

  2. String Array StraingArray = strInputText.Trim.Split(":61:".toCharArray)

  3. For each item in (StringArray)
    {
    item (message box)
    }

I expected it to work but it is showing BAD result.

Kindly look into it.

Thanks and Regards,
@hacky

Hi @hacky,

split.xaml (5.3 KB) InputStr.txt (1.1 KB)

Getting results as per your comments!

Please have a look.

Note: Difference between Char array and string array,

  1. arr={‘s’,‘h’,‘b’,’r’} - Char array
  2. arr={‘hello’, ‘good’ ,‘day’, ‘please’} - string array

Thanks!

3 Likes

@kadiravan_kalidoss

Looks fair!

it helps… Thank you very much.

Also I request you to review my question, as I am splitting, I am expecting the sections as:-

:61:1409030903CY12,40NTRFNONREF//NONREF
LP4140902YLP70000006
:86:/OR/LP4140903YLP70000006
/ORDP/付款方名称付款方名称付款方
名称付款方名称付款方名称付款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明
/VA/0000000001

where as section is shown as:

1409030903CY12,40NTRFNONREF//NONREF
LP4140902YLP70000006
:86:/OR/LP4140903YLP70000006
/ORDP/付款方名称付款方名称付款方
名称付款方名称付款方名称付款方名
/REMI/付款明明细付款明明细付款明
明细付款明明细付款明明细付款明明
/VA/0000000001

As in, it is ignoring the “:61:” part which is required in my case.
Kindly suggest.

Regards,
@hacky

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.