Regex Expressions Omitting Text


If I am given a phrase I want to only extract certain things from that phrase and skip certain parts of the phrase.

For example given

Total Balance Mar04 $76.88

I would like to skip the text after balance and before the $ sign. The text is constantly changing and I need to omit any text between them if there is any.

The expression I have so far is listed below and it works when there is no text in between but does not work when there is text in between.

((?<=Amount Due|Pay This Amount|Total Balance Due|Total Current Month’s Charges|Amount Now Due|Total Amount Due)\s+($).*)

@Sahil_J_Patel - you wanted to captured only the amt without the dollar symbol?

Can you please provide couple of variations? Ie…with and without

Yes only want to capture value without the dollar sign.

Pay this amount $45.50 → works with current expression

Pay this amount due Mar04 $56.67 → Does not work with current expression

Amount due $56.78 → works with current expression

Amount due on dec4 $76.45 → does not work with current expression

Total balance $76.45 → works with current expression

Total balance on apr3 $64.34 → does not work with current expression

@Sahil_J_Patel - Please verify and give it a try…

Unfortunately, it did not

work. It now highlights Mar04 as well.

Unfortunately, this did not work.

@Sahil_J_Patel - As I mentioned in the other post, I am not how to get it…

If you have always amount at the end of the line…then you have try this…

(?<=Amount Due|Pay This Amount|Total Balance|Total Current Month’s Charges|Amount Now Due|Amount Due|Amount due on|Total Balance on).*\$([\d.,]+)$

May we ask you to be more specific (what was done, what is failing).
as you can see in the screenshot from Regex 101 it was marking the amounts
so lets find out what is the difference

as an alternate we maybe can fetch text and amount as well:
Case ignore is activated:

1 Like

How could I use this same expression and get the same result if the $45.67 was on the next line?

Ex: Pay This Amount

Never mind I was able to figure it out.

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