Describe this expression

Hi @Lakshya_Garg ,

Let’s break this Expression into individual pieces and Explain

Let’s take an Example String as well :

gettext= "Client ID : 1111212 
          Client Name : Jack"
  1. gettext.Substring(gettext.IndexOf("Client ID: ")+"Client ID: ".Length)

The Above Expression is using a String Substring Method.

The Syntax goes as below :

String.Substring(startIndex, length)

startIndex - An Integer value indicating the position from where the start of the String should be selected. (Should not be greater than the Length of the String-1)

From your Expression, You are retrieving the Start Index of the Client ID: String and you are adding the Total Length of the Client ID: String to it.

We can use the Debug Panel to Check the Expression Individually :

Combining the Two in the Substring Method would provide us the below result :
image

  1. Next Expression, Split(Environment.NewLine.ToCharArray)(0) , the Split Method Applied on the Substring Resultant value.

Split - As it is named, Splits the String based on a delimiter.

Syntax is as below :

String.Split(delimiter) :

Let’s take it directly to the Debug Panel :

What we would need is the Client ID value from the String, In the String as observed we have a New Line followed by the Client Name values. To Separate the Client Name from the Client ID value, we use the Split method with New Line as the Delimiter resulting in the below as shown :

As Explained by @Nithinkrishna , Split(Environment.NewLine.ToCharArray) would split the value into multiple lines. The Split(Environment.NewLine.ToCharArray)(0) would take the First Split Value

image

Let us know if you Still need more explanation on the above.

7 Likes