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?
ushu
(Usha kiranmai)
April 20, 2023, 7:31am
2
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
Is it possible to share the screenshots of the workflow here? I am unable to download any files in my work laptop. Appreciate much
ushu
(Usha kiranmai)
April 20, 2023, 8:22am
4
@flyingdragon -
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
Take For Each activity, assign a variable to Index property
Inside the loop, take Add Data Column activity, to add a column in data table (dynamically adding, you can change accordingly)
Take Add Data Row activity to add a row in data table
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
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?
ushu
(Usha kiranmai)
April 21, 2023, 5:54am
7
@flyingdragon - Let us know if you face any issues
system
(system)
Closed
April 24, 2023, 5:55am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.