3 Replies Latest reply on Dec 31, 2014 2:37 AM by Peter Spier

# GREP equation with pricing

I would like dollar and cent pricing to follow a specific format: The dollar sign (\$) is superscript in size. The dollar amount (anywhere from 1 to 999) is regular text. And the 2-digit cent amount is also superscript in size with an underline option applied.

If I have character styles for the dollar sign, the dollar amount, and the cent amount, is there a GREP equation that will force the pricing to follow this format? See the example below.

Any help is appreciated. Thanks.

• ###### 1. Re: GREP equation with pricing

You can use two GREP styles as part of the paragraph style, or use the same expressions in Find/Change:

For the \$ use either \\$ or [\$] and for the cents use (?<=\d\.)\d\d (that's a positive look-behind for a digit and decimal point, then two digits).

• ###### 2. Re: GREP equation with pricing

Peter.

What if don't have a decimal point in the pricing? I was hoping that GREP could just recognize that the last two digits would be the cents.

• ###### 3. Re: GREP equation with pricing

Peter,

I think I figured it out. I omitted the \. from the first part of your equation in parenthesis, and added a \$ (end of paragraph marker) at the end of \d\d.

So far that works perfectly.

• ###### 4. Re: GREP equation with pricing

Hi Peter,

More precisely: 3 grep styles (if prices are alone in paras)

\\$(?=\d+\.\d\d)

(?<=\d)\.(?=\d\d)

(?<=\d\.)\d\d

The second regex to make the dot invisible.

• ###### 5. Re: GREP equation with pricing

Yeah, it was a long day yesterday and I forgot about the decimal point.