Hi,
Im attaching a text file I need to get the values below extra charges using regex. How to provide that.
Can any one please explain.
I need to get these two values
~Gas-Delivery Service~$~20.57
~Packing-charges~$~5.20
Sample_Text.txt (335 Bytes)
Anil_G
(Anil Gorthi)
May 24, 2023, 10:38am
2
@Chippy_Kolot
Please try this regex
(?<=Gas-Delivery Service~\$~).*
For the next replace gas delivery service with the packing charges
Read the text fie into str then
System.Text.RegularExpressions.Regex.Match(str,"(?<=Gas-Delivery Service~\$~).*").Value
Cheers
Hi, In my use case I need to extract
~Gas-Delivery Service~$~20.57 and ~Packing-Charges~$~5.20, not only amount.
I need those two line item
Anil_G
(Anil Gorthi)
May 24, 2023, 10:41am
4
@Chippy_Kolot
Remove the lessthan symbol you will get whole
Cheers
Lekshmi_R
(Lekshmi R)
May 24, 2023, 10:45am
6
Hi,
Can you try this one:
Anil_G
(Anil Gorthi)
May 24, 2023, 10:50am
7
@Chippy_Kolot
Try this
(?<=Extra Charges:).*(?=~SUB-TOTAL)
System.Text.RegularExpressions.Regex.Match(str,"(?<=Extra Charges:).*(?=~SUB-TOTAL)",RegexOptions.SingleLine).Value.Trim
Cheers
jamago
(Jomari Amago)
May 24, 2023, 1:50pm
8
Hi @Chippy_Kolot ,
If you want a more dynamic approach to capture the extra charges (which is possible if a user has purchased extra items besides gas delivery and packing charges), might as well capture anything in between the “Extra Charges:” and “SUB-TOTAL” strings. Here’s the regex pattern:
To access this in a UiPath variable, you can use assign activity with the following values:
Assign: VariableName = System.Text.RegularExpressions.Regex.Match(ValueFromTextFile,“~Extra Charges:\n(?s)(.*)~SUB-TOTAL”).Groups(1).Value
You can clean this string by removing empty lines and using .Trim string functions. Up to you.
Cheers.
system
(system)
Closed
May 27, 2023, 2:52pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.