How to extract the Specific data from the string or text File

Test - Copy.txt (544 Bytes)
Test.txt (635 Bytes)
Hello ,

I need to extract the CR Amount and Reason from the Attached text Files

Case 1
Bank: 288

The following 1 ACH batch for COUNTER FORM PYR (Company ID: ******43613) requires your attention:

CR Amount CR Count DR Amount DR Count Settle Date SEC Entry Desc File ID Batch No Disposition Reason(s)
$42,542.38 1 $0.00 0 6/8/2023 PPD AchBatch 23158002973 0000013 Suspend Exceeds ACH Limits

Do not reply to this message. If you have any questions about this alert, contact FIS Client Care Support 844.6 FIS NOW or 844.634.7669. Please have your Entity ID available for security validation.

Case 2

The following 1 ACH batch for COUNTER FORM PYR (Company ID: ******43613) requires your attention:

CR Amount CR Count DR Amount DR Count Settle Date SEC Entry Desc Reason(s)
$42,542.38 1 $0.00 0 6/8/2023 PPD AchBatch Suspend: Exposure Limit

Do not reply to this message. If you have any questions about this alert, contact FIS Client Care Support 844.6 FIS NOW or 844.634.7669. Please have your Entity ID available for security validation.

Please find the Attached Files.

Case 1 Out Put
var_CR_Amount = $42,542.38
var_Reason= Exceeds ACH Limits

Case 2 Out Put
var_CR_Amount = $42,542.38
var_Reason= Suspend: Exposure Limit

Thanks,
Nitesh S

Hello Nitesh,

Can you explain what kind of result you want? Including Case1 and Case2.

Br
Amos

Hi @nitesh.s

Here is Regular expression to extract the CR Amount

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\n)\$[\d.,]+").Tostring

Regards
Gokul

we can work with Regex

Amount:

Also the combination on line filtering in advance and then using regex can help to find a more compact approach

[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

Hi,

Can you try the following sample?

m = System.Text.RegularExpressions.Regex.Match(currentItem,"(?<=CR Amount.*?Reason\(s\)\r?\n)(?<CRAMOUNT>\$[\d.,]+).*?\s(?<REASONS>(\s\S+)+)(?=\r?\n)")

then

m.Groups("CRAMOUNT").Value
m.Groups("REASONS").Value

Sample20230621-5L.zip (3.6 KB)

Regards,

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