I want to read each line that starts with ‘Task’ in the below string.
further,1. I have to pick-the initial no,i.e between ‘task:’ and ‘description’.
2.I have to capture the code between 'description: and ‘-’,
3.extract text between ‘-’ and Price.
What I did is first used used regex pattern '“(?<=” + labelBefore + “)(.*?)(?=” + labelAfter + “)” and removed whatever is above ‘Task’ and before ‘Thank you’
then splitted data on the basis of string.split(“Task”) and used for each to get ‘item’-each row.
Now how to extract the values from item(one row).
below is the input string:-
This is regarding reference number 826123, the following info have been identified:
Task: 18212402 Description: 121 - gas leakage ,not completed Price: $98.50
Task: 32321720 Description: Rejected Price: $0.00
Task: 34017280 Description: 131 - This will be repaired once spare available Price: $38.50
Task: 66017240 Description: 139 - sent for repair Price: $16.50
There could be single or multiple rows starting with Task,how am i gonna check those.
I thought of splitting first on the basis of Task,and inside for each use this regex.
But giving error in for each.
These expressions would take any number rows after Task
But the described delimiters like Task, Description, -, Price must be there along the strings
If they are present then we would get the value in between them for sure
May I know what was the error you were getting in for each loop
Because I tested with regex101.com with those expressions and it was working fine, giving all the outputs correctly
@Palaniyappan,the regex is working fine,my question is…if i
use String(0).value.ToString.Trim it will give me result of only first value with (0),how to make this dynamic,there could be one ,two or n no of result.
Fine got it
Let’s go step by step
—once after using this expression in a Matches activity
Get the output with a variable of type from that activity
—then use a for each activity where pass that variable as input and change the type argument as System.Text.RegularExpressions.Regex.Match
—then inside the loop use a writeline activity like this item.ToString.Trim
This will type all the values of each match one by one
Similarly repeat the same for other matches with a for each loop followed by that
tick modifier Multiline
you should then loop foreach founded matches and
access to the requred isubstringg by names
( smthing like .Groups.Item(“Name”).value )
Substrings Names are:
TaskNo - for task number
DescriptionCode for number after Description
DescriptionBody for text after code
Price is for price
just noticed that website eats some symbols in regex . hope I would able correctly expose them