Hi,
I have been working for a complex project, for that a regex extraction is required. For some of regular expression, I have designed. But for others am struggling.
I need support to design the REGEX for strings am struggling for, strings are listed below.
Total nett amount: CZK 4,305.52
Here I need regex to capture the amount
Weight (gross / nett): 48.50 / 48.50 KG
here I need the regex to capture the both weights.
Your help will be appreciated.
Thanks & Regards,
Baruna K Panda
Gokul001
(Gokul Balaji)
August 25, 2022, 7:52am
2
Hi @Panda_Baruna_K
System.Text.Regularexpressions.Regex.Match(yourString,"(?<=CZK\s)(\S+)").tostring
Regards
Gokul
Gokul001
(Gokul Balaji)
August 25, 2022, 7:54am
4
@Panda_Baruna_K
System.Text.Regularexpressions.Regex.Match(yourString,"(?<=gross\s\/\snett\):\s).*(?=KG)").tostring
Regards
Gokul
Gokul001:
"(?<=CZK\s)(\S+)")
Hi Gokul,
The problem with the expression is, “CZK” you have taken reference is dynamic value, so it will change for other data. Only “Total nett amount:” is constant.
Thanks,
Baruna K Panda
Gokul001
(Gokul Balaji)
August 25, 2022, 7:56am
6
@Panda_Baruna_K
System.Text.Regularexpressions.Regex.Match(yourString,"\d.*").tostring
Hi Gokul,
It is capturing though, but it is capturing both at one go. I need to capture one by one, both are separate values & also dynamic in nature.
Thanks
Baruna K Panda
Gokul001
(Gokul Balaji)
August 25, 2022, 8:01am
8
Hi @Panda_Baruna_K
System.Text.Regularexpressions.Regex.Match(yourString,"\d.*(?=KG)|\d.*").tostring
Regards
Gokul
Sanjit_Pal:
\d.+\d
Hi Sanjit,
the expression is matching for multiple values in the string, can we capture the “Total net amount:” string only.
Thanks
Baruna K Pada
Gokul001
(Gokul Balaji)
August 25, 2022, 8:07am
10
Hi @Panda_Baruna_K
System.Text.RegularExpressions.Regex.Match("Total nett amount: CZK 4,305.52","(?<=amount:\s)\D+(\d.*)").Groups(1)
Regards
Gokul
1 Like
Sanjit_Pal
(Sanjit Pal)
August 25, 2022, 8:16am
11
Hey @Panda_Baruna_K ,
You can use look after method to get the desired result.
(?<=Total net amount:\s)\d.+\d
Thanks,
Sanjit
1 Like
I have found another way to capture that.
i.e (?<=Total nett amount: [A-Z]{3}\s)[\d,.]+
Thanks Sanjit for all your support.
1 Like
Hi Gokul,
Thanks for sharing it, I have found a an expression to capture that.
i.e (?<=Total nett amount: [A-Z]{3}\s)[\d,.]+
I appreciate your help.
Thanks.
1 Like
Gokul001
(Gokul Balaji)
August 25, 2022, 9:29am
14
Hey @Panda_Baruna_K
The above regex is not working?
Gokul001
(Gokul Balaji)
August 25, 2022, 10:43am
16
This expression is not working ? @Panda_Baruna_K
1 Like
Gokul001:
(?<=amount:\s)\D+(\d.*)
I think this is better, the solution it was chosen i doesn’t work for me either
1 Like
system
(system)
Closed
August 29, 2022, 9:53am
18
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.