Read Line

HI TEam,

I have a line say

ABCD EFGH POSTAL CLASS 1

Bot has to ignore POSTAL CLASS 1 and should extract every thing which before the word POSTAL.
Output should be - ABCD EFGH . Values before POSTAL may increase or decrease say 1 word, 2 or 3 words also…

@Robotics,

Considered that you are passing your string with strInput variable.
Then try with the following line of code, this will help.

strInput.Substring(0, strinput.IndexOf("POSTAL"))

@Robotics

str = ABCD EFGH POSTAL CLASS 1

Below 2 methods will gives you required result.

str.split({“POSTAL”},StringSplitOptions.RemoveEmptyEntries)(0)

Split(str,“POSTAL”)(0)

@ Sarathi your code is working fine.
@ Manjuts thanks for your update as well.

1 Like