Search/Replace Variable Prices

Learn / Forums / General InDesign Topics / Search/Replace Variable Prices

Viewing 2 reply threads
  • Author
    Posts
    • #64611

      Hi everybody,

      I’m requesting your help, because I have some troubles to find an productive solution and i’m sure i’m missing some knowledges to have it done.
      So, I have an international magazine with a bunch of price points like this;
      US?$65
      CA?$80
      EU €70

      For the publication of the magazine in Quebec, I need to change the sign of currency by place like this:
      65$ US?
      80$ CA?
      70€ EU

      Does anyone know if there is an easy way to do it by search and replace, by changing the order but keeping the digit prices?

      Thx for your help

    • #64616
      Justin Sligh
      Member

      Christophe,

      Assuming a few things:
      1. Currencies are whole numbers.
      2. There are no spaces after the “?” in your international version (In your example, US?$65 CA?$80 have no space but EU €70 does. Was this intentional or did the forum adjust your post automatically.)

      Grep Find:
      (US\?|CA\?|EU )(\$|€)(\d+)

      Change to:
      $3$2 $1

      We are asking InDesign to:
      1. Find “US?”, “CA?”, or “EU ” and set as variable “$1”; find a “$” or “€” and set as variable “$2”; and find one or more consecutive digits and set as variable “$3”
      2. Paste variable “$3” followed by “$2″ followed by a space and then” $1″

      () Items within parentheses are sub-expressions and can be used as variables within the Change to. If you find (Red)(Blue)(Green) $1 is “Red” $2 is “Blue” and $3 is “Green”.

      ? and $ are functions used by grep so to look for actual characters, you need to escape them using a backslash “\”

      \d indicates a digit
      + indicates one or more of the previous.

      • #64617

        Hi Justin,

        thx this is amazing!!! The question marks that you was asking about should supposed to be a thin spaces.
        So it should be:
        US?$65 CA?$80 UK?£70 (the “?” is actually a thin space)

        replaced by:
        65$?US 80$?CA 70£?UK (the “?” is actually a thin space)

        Sorry for that mistake

        I tried:
        (US~<|CA~<|UK~< )(\$|£)(\d+)

        But it didn’t really work…

    • #64618
      Justin Sligh
      Member

      Christophe,

      Do you have a mix of different types of whitespace between the original text?

      You can use:

      (US|CA|EU)\s(\$|€)(\d+)

      $3$2~<$1

      This will find the country code than any whitespace character followed by the currency symbol and then digit(s).

      The replace string adds a thin space regardless of the type of whitespace within the find.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
>