I have a string in below format. The values and spaces between each string are dynamic. Need help in extracting the values and storing them in different variables.
For instance,
In Complete 02/25/2023 23653874109 ($700.00) 13 Care and Care Plan
Pending for Review 11/12/2021 73481250986 $1253.30 28 Child Health, Health Care Plan
The above lines will be processed individually. For every line the expected output is in below format.
variable 1 = should have all words before date (i.e In Complete)
variable2 = date (i.e 02/25/2023)
variable3 = ID (i.e 23653874109)
variab1e4 = amount (i.e ($700.00))
variable5 = number (i.e 13)
variable6 = should have all the words after the number(i.e Care and Care Plan)
Same for the rest of the lines
I hope you find the solution for your query, If yes Mark my post as solution to close the loop.
Else, If you have any queries or clarification, let me know… @kavya_mamidishetti
mc = System.Text.RegularExpressions.Regex.Matches(strData,"(?<=^|\n)(?<STATUS>.*?)\s+(?<DATE>\d+/\d+/\d+)\s+(?<ID>\d+)\s+(?<AMOUNT>\S+)\s+(?<NUMBER>\d+)\s+(?<NOTE>.*)")
Then we can access each value like m.Groups("DATE").Value
@mkankatala I appreciate your efforts. The syntax for variable3 i.e for amount it is failing to extract the amount when the digits increased for the amount. For example, ($7,901.00) , ($12,501.00). Since, data is dynamic I’m not sure of the length of digits length. Would you mind looking at please?
@mkankatala It is able to extract the amount now but variable6 syntax is not working in some cases to extract the number. Please find below screenshot for your reference. Unable to extract number 33 with the current syntax.
Thank you,
Sorry there is change in the Price right ($7,382.00) according to this I have made changes to that regular expressions, check below one now these work for Variable5 and Variable6.