Regex to extract the third set of amount or number

@AhmedKutraphali - You can try this…

1 Like

@prasath17

It was not able to get this 3081.00

Total Code : 432-000-3117-000-00 12804.00 9723.00 3081.00

@AhmedKutraphali - It is working as expected…Please check below…

1 Like

Ive change it to (?<=Total for GL Code :\s?)[\d-]{19}(\s+\S+){3}\s?(?[\d.,-]+)

Thank you @prasath17 . how did you become so good at regex ? what did you study to master it ?

@AhmedKutraphali - First I have started with this video. If you ask me what is Regex couple of months before, I am literally 0 :joy: .

Watched this video and practiced one whole day from the concepts I learned from that video. Once you grab the concept then you will become master.

BTW: I am still learning…not master :wink:

1 Like

Thank you for this @prasath17 . By the way would this works on the new regex ? YourRegexVariable(0).groups(“ThirdAmt”).tostring ? for example on getting this value

432-000-3117-000-00 12804.00 9723.00 3081.00

output : 3081.00

@prasath17

I tried this YourRegexVariable(0).groups(“ThirdAmt”).tostring to 432-000-3117-000-00 12804.00 9723.00 3081.00 it did not get the correct value which ois 3081.00

@AhmedKutraphali - Please check this…Regex_Ak.zip (176.3 KB)

try wit this value bro for example 432-000-3117-000-00 12804.00 9723.00 3081.00

output should be : 3081.00

CRAP , the current regex above this not include the 174.26

@AhmedKutraphali - please check the code which I provided…it is capturing all the values which you have provided…did you check that??

Add your input and run the code…and share your workflow and output…

Ive replace {2} with {3} (?<=Total for GL Code :\s?)[\d-]{19}(\s+\S+){3}\s?(?[\d.,-]+) now it gets the set of numbers
sample output : 432-000-3117-000-00 12804.00 9723.00 3081.00

but how do we get the last set of number ? like for example above output should be 3081.00

I tried your Item.Groups(2).ToString but it did not work. Thanks

@AhmedKutraphali - Did you refer my screenshot above? where it captured the 3081 clearly…I am not sure what you are trying. I have already provided the code sample too…

Take your text and pattern and put it in the .NET Regex Tester - Regex Storm.

here is the link for your pattern.

@prasath17 but it did not work in this one , as you can see on the screenshot

@AhmedKutraphali - Please provide the proper input …does your text starts with Total Code : or not??

@AhmedKutraphali - Check this…I have adjusted the pattern. Previous pattern did not work, because 14-000 etc has only 18 characters…thats why…

Yes , try this one @prasath17

Total Code : 516-000-3417-000-00  174.26  0.00  174.26

Total Code : 421-000-31220-000-00  901,358.63  1,264,111.83 -362,753.20


21983 Purchase Order  1.00  840.96 -840.96
Total for Supplier : 78225020 - South-East Lumber Co  0.020  8340.96 -8340.96

20978 Purchase Order  0.00  1,2533.60 -1,263.60
Total for Supplier : 790230T10 - Flooring  0.00  1,263.60 -1,263.60

Total Code : 421-000-3110-000-01  901,358.63  1,264,111.83 111,743.20
Total Code : Handling Fee 435.00 0.00 435.00

@AhmedKutraphali - Check this…You have multiple spaces before 174 so changed \s? to \s+

Updated:

1 Like

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