Home > Software engineering >  Extracting currency value in Google Sheets with regex
Extracting currency value in Google Sheets with regex

Time:06-14

I am trying to extract the tip value from columns in Google Sheets. What would be the proper regex argument to use to do this? Some columns do not have the tip value, and in this case i would like it to return "0".

Tip - 20% x $134.00Damage Waiver: 5% x $40.20Coupon: Thanks for considering us!! x -$10.00Tax: 7.25% of $700.20 x $50.76

CodePudding user response:

If the input string (let's say at A1) has the word "Tip", and the first dollar symbol after that initiates the amount of interest, then do:

=IFNA(VALUE(REGEXEXTRACT(A1, "\bTip\b[^$]*\$([\d.] )")), 0)

This expression will produce a number type, so the dollar is not included.

Apply the desired number formatting to the cell where you place this formula to show a currency symbol, and the required number of decimals.

  • Related