Splitting a particular line


I scrapped the text from cmd and stored it as a variable. There are some 7 to 8 lines in that text.
I need a particular line to be splited and save it as a variable. Please suggest. I have uploaded my case. I need only the path text F:\series\Dark

You can find the needed text with a simple string methods.

  1. Find Index of Directory of (index1 = yourstring.IndexOf("Directory of") + "Directory of".Length)
  2. Find Index of new line character after Index of “Directory of” (index2 = yourstring.IndexOf("\n",index1))
  3. Use sub string to extract the path (path = yourstring.SubString(index1, index2-index1))

Hi karthik
Thanks for your response.
I am new to this, could you please provide a .xaml file for my scenario that I mentioned above, selecting the path text only from the scrapped text and store it as a variable.
Thanks in advance

Hii Newton,

You can also use the regex "(?<=Directory of\s)[A-Z]:\\[\\.\w_-]+" for extracting the path.
Please check the workflow Regex-Path-Extract.xaml (5.9 KB)

Warm regards,

1 Like

Use below code in assign
yourvariable.Split({“Directory of”},StringSplitOptions.removeEmptyEntries)(1).split({Environment.Newline},StringSplitOptions.removeEmptyEntries)(0)

Thanks Nimin

It worked. It was helpful

1 Like

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