Hello Community,
I need little expertise on extracting string value using regex.
Total Overpayment $27165.04 Segments tagged/OP ID/amount of overpayment: “04 72750668 5399.96 05 72750669 6291.83 07 72750672 72.75 10 72750678 8370.54 11 72750680 7029.96”
Need to extract bold text only , each value trimmed.
Hi @Sahil_Garg1 ,
For Starters, could you check with the below Regex Expression :
(?<=amount of overpayment:).*?(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)
We would need to access the required values using Groups.
Debug Panel :
Regex.Match(strText,"(?<=amount of overpayment:).*?(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)\s[\d.,]+\s(\d+\s\d+)").Groups(1)
Do note that we only received a Single Sample text, the regex expression could also vary for different formats, do check this with multiple samples and confirm if it works or not. For the given format or pattern, the Regex should be good.
1 Like
mate, if u see third post by @lrtetala , this regex seems very short and good to save, will try both once .
working fine mate currently, also can you help on extracting that dollar value also
$27165.04
lrtetala:
$\d+.\d
working fine
$\d+.\d{2}.
Can you tell how u r making these expression, like knowledge only or some source ? i always get stuck in regex.
ppr
(Peter Preuss)
October 7, 2023, 4:13pm
10
Sahil_Garg1:
or some source
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommited…
Regex101.com gives us also some explanations which helps for learning
1 Like
thanks a lot @ppr and @lrtetala for your quick response, and cheatsheet.
1 Like
system
(system)
Closed
October 10, 2023, 4:16pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.