Need to extract text in each line before and after ","

Hi Everyone,

i have a text

Text123.txt (4.1 KB)

i want to get each line last sentence before and after “,”

For Example ,

one line
,○,○,○,○,22,LABEL TAPE,----------,9S6-7010,1,PAPER ,PRODUCTION CONTOROL LABEL,

PRODUCTION CONTOROL LABEL

Thank you!

@victoryv4569,

Split the string with , and get the second last index value.

strOutput=strInput.Split(",")(strInput.Split(",").Count-2)

Output:
image

Thanks,
Ashok :slight_smile:

1 Like

Hi @victoryv4569

textBeforeLastComma = inputLine.Substring(0, inputLine.LastIndexOf(",")).Substring(inputLine.Substring(0, inputLine.LastIndexOf(",")).LastIndexOf(",") + 1).Trim()

textAfterLastComma = inputLine.Substring(inputLine.LastIndexOf(",") + 1).Trim()

Regards,

1 Like

@victoryv4569

lines = fileContent.Split({Environment.NewLine}, StringSplitOptions.None)
For Each line in lines
lastCommaIndex = line.LastIndexOf(","c)
beforeLastComma = line.Substring(0, lastCommaIndex).Trim()
afterLastComma = line.Substring(lastCommaIndex + 1).Trim()
1 Like

Hi @victoryv4569 ,

Could try with the below Expression as well :

Split(strText.Trim(",".ToCharArray),",").Last.trim

From Debug :
image

1 Like

Hi @victoryv4569

I have Solved it, you change it according to you now.
Main.xaml (31.7 KB)

Cheers.

1 Like

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