Required expertise on Regex

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)

image

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

Hi @Sahil_Garg1

Try this

Hope this helps!!

mate, if u see third post by @lrtetala , this regex seems very short and good to save, will try both once .

@Sahil_Garg1

\d{2}\s+\d{8}

working fine mate currently, also can you help on extracting that dollar value also

$27165.04

@Sahil_Garg1

\$\d+\.\d+|\d{2}\s+\d{8}

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.

Regex101.com gives us also some explanations which helps for learning

grafik

1 Like

@Sahil_Garg1

1 Like

thanks a lot @ppr and @lrtetala for your quick response, and cheatsheet.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.