9 Replies Latest reply on Feb 4, 2016 1:16 PM by Reese 0o0o

# GREP to select a full dollar amount?

I need to find a dollar amount in a line. The amount is of an unknown number of digits. This is almost working. \d+?\,?\d+?\.\d+ But it is not selecting numbers that only have one digit before the decimal point. ie. it will select 5,500.00 and 500.00 and 50.00 but NOT 5.00 Suggestions? Thanks!

• ###### 1. Re: GREP to select a full dollar amount?

(\d{1,3},)?(\d{1,3},)?(\d{1,3},)?(\d{1,3}?)\.\d{2} seems to work up to 999,999,999.99 and picks up as little as .00 too

• ###### 2. Re: GREP to select a full dollar amount?

Nice Peter!

I was plunking away at that...you're code gives a nice example of how to string together conditionals, which I was in sore need of.

• ###### 3. Re: GREP to select a full dollar amount?

Thanks Peter! That worked. Very much appreciate your help!

• ###### 4. Re: GREP to select a full dollar amount?

It doesn't seem to pick up, '.00', without any whole numbers preceding in my testing

• ###### 5. Re: GREP to select a full dollar amount?

(\d{1,3},)?(\d{1,3},)?(\d{1,3},)?(\d{1,3}?)?\.\d{2}

I believe you need 1 more 'zero or one' times '?' to catch just a decimal number

• ###### 6. Re: GREP to select a full dollar amount?

Reese 0o0o wrote:

It doesn't seem to pick up, '.00', without any whole numbers preceding in my testing

That's because I misplaced a ) when I typed it here.

Should be (\d{1,3},)?(\d{1,3},)?(\d{1,3},)?(\d{1,3})?\.\d{2}

• ###### 7. Re: GREP to select a full dollar amount?

Great!

• ###### 8. Re: GREP to select a full dollar amount?

Hi Peter,

I'm tired tonight but maybe this can play the game for this:

\$1,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999 ,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,9 99,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999 ,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,9 99,999,999,999,999,999,999,999,999,999,999,999,999.99

(,?\d{1,3}\b)*\.\d{2}

• ###### 9. Re: GREP to select a full dollar amount?

Oooo...

Beautifully done!