Extract certain text from string

Hi,

Need help. I want to extract some text from string and write to datatable

Example:
Input
Hi,
Pls follow up.
[Info] Please provide the information. AA,BB,CC,DD
[Info] Please provide the information. CC,DD,AA,BB

Output
For the first row of “[Info]”, write AA,BB,CC,DD under column 1. For the second row of “[Info]”, write CC,DD,AA,BB under column 2.

The input varies. There could be 2 rows and can be up to 15 rows. The common identifier is “[Info]” How do i ask the bot to perform this?

Hi @flyingdragon - You can apply regex to get the data

System.Text.RegularExpressions.Regex.Matches(Input,"(?<=\[Info] Please provide the information.\s+).*")

Please check the below workflow and check how that helps

SampleWorkflow.zip (24.9 KB)

Output

Picture1

Is it possible to share the screenshots of the workflow here? I am unable to download any files in my work laptop. Appreciate much

@flyingdragon -

  1. Take Assign activity
Variable of type (System.Text.RegularExpression.MatchCollection) RegOutput = System.Text.RegularExpressions.Regex.Matches(Input,"(?<=\[Info] Please provide the information.\s+).*") 

Input variable has the input string data

  1. Take For Each activity, assign a variable to Index property
  2. Inside the loop, take Add Data Column activity, to add a column in data table (dynamically adding, you can change accordingly)

  1. Take Add Data Row activity to add a row in data table

  1. Take Assign activity to insert the data into a row
DT.Rows(0).Item(Index) = currentItem
  • Index is the variable assigned to Index property of For Each activity
  1. Take output data table activity after For Each to convert the data table to text and finally print the text in a message box

Thanks for the help. But my For Each Activity looks different from yours. If i can only use my version, what should be the correct input?

@flyingdragon

@flyingdragon - Let us know if you face any issues

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