Please explain function of each keyword in this string manipulation command

this is to extract just this text - “RO874232” ahead of TaxID in webpage.

command - Clientinfo.Substring(Clientinfo.Indexof("TaxID: ") + "TaxID: ".Length).split(Environment.NewLine.ToCharArray)(0)
where Clientinfo is the output of get text activity which is selecting the whole block.

So, what is your question? Are you able to extract the values @Gaurav07

yes I found this code online and its working , I just want to know how it works and what each keyword means

text.Substring(text.IndexOf("TaxID: ")+"TaxID: ".Length).Split(Environment.NewLine.ToCharArray)(0)

Here text is the entire text you have @Gaurav07,

Indexof gives the starting index of the TaxID , I mean, the starting character position,

TaxID length represents the number of characters in the string TaxID… So,

we are giving the index as the starting of TaxID + length of TaxID , so it will start with the actual value we need.

Then split (newline) represents to split the text upto the next new line character and then (0) represents before the new line. If we give it as (1), it will gives us after the new line

Hope this is very clear @Gaurav07

4 Likes

can you elaborate this part -
Then split (newline) represents to split the text upto the next new line character and then (0) represents before the new line. If we give it as (1), it will gives us after the new line

I mean, it will split the string based on the new line character

for example,

This is the first line
and this is second

If this is the texxt you have and if you split it as text.split(Environment.Newline), it will store the first line and second line in an array of type string

so, if you want first line, text.split(Environment.Newline)(0) will give you the first line and

text.split(Environment.Newline)(1) gives the second

1 Like