grepadobe-indesigngrep-indesign

Grep: How to only find the first price mentioned in a line of text


I have a bunch of variable text in Adobe Indesign and I'd like the first mentioned price in each line of text to have another color. I am completely new to regular expressions and got stuck. I used the following grep to find the price but it find's all prices mentioned in the text.

€[0-9]+([.,][0-9]+)*

The text is like below and I need to get only the bold prices:

Spend €99,99, get €25 off

Spend €150, get €35 off

I tried lot's of things mentioned on stack overflow and online but just can't find the right solution. Adding ? at the end to make it lazy doesn't do the trick. I think I need to do some grouping on the grep-code but can't find the right way to do so. Any help would be great!


Solution

    1. create two character styles "Bold" and "Roman", the latter should be the same character style as in your paragraph style.

    2. Create two GREP styles. The first one should apply character style "Bold" to text with the following pattern:

      ^.*?(€\d+(?:,\d+)*)
      

      the second one should apply character style "Roman" to text with the following pattern:

      ^.*?(?=€)
      

    enter image description here