Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Script for moving $ to end of numbers

New Here ,
Nov 10, 2017 Nov 10, 2017

I have an english indesign file that was translated to french.  The last thing to be changed are the dollar values.  In english they appear like this $1,200 and in french it needs to have a space followed by the dollar sign at the end of the number and with a space instead of a comma like this 1 200 $

There are hundreds of numbers so I am trying to figure out a way to use the find/replace feature but I am struggling.  Any advice would be greatly appreciated.

Catharine

TOPICS
Scripting
677
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Nov 10, 2017 Nov 10, 2017

Find: (^\$)(\d+)(,)(\d{3})\b Chage:$2 $4 $1

Translate
Engaged ,
Nov 10, 2017 Nov 10, 2017

Hi,

Try this..

Find: (\d+) (\d+) (\$)

Replace: $1,$2$3

Thanks,

Prabu G

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 10, 2017 Nov 10, 2017

Find: (^\$)(\d+)(,)(\d{3})\b Chage:$2 $4 $1

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 10, 2017 Nov 10, 2017

Hi,

Nobody said it was a beginning of para.

A no-break (or thin space) before $ could be cool.

Idem as thousand separator.

Everybody suppose we'll never have more than 999,999!

Try:  $1,000,000,001

(^/) 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 10, 2017 Nov 10, 2017

Hi all.

How is this expression?

find: \$ *(([1-9]{1,3}\,?([0-9]{1,3}\,?)*)+)

change: $1 $

However, this does not take decimal into consideration.

Regards,

Yusuke.

Yusuke S.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2017 Nov 12, 2017

You have no idea how excited I am that this works!! You are a genius! Thank you so much for your response.  I wish I understood enough about scripting to be able to modify this but I don't so I have 1 further request.  This works for all numbers with a comma but I have many numbers that are only 2 and 3 digits long therefore not requiring the comma.  ie $50 or $300 This script doesn't work for these. Are you able to give me a script that will now work on these numbers?

Catharine

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2017 Nov 12, 2017
LATEST

I just realized my response did not mention who's script worked but it was uniqued_tol.  Thanks again but no need to send the second one as I had requested because I realized that Obi-wan Kenobi's first script fixes the ones without commas.

Thank you everyone for taking the time to reply 🙂

Catharine

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 11, 2017 Nov 11, 2017

Supposing you could have 1 billion of dollars or just 1 dollar in your pocket, you'll need 2 regex to fix it!

1/

Find:  (\$)([\d,]*\d)

Replace by:  $2~s$1

2/

Find:  \d\K,(?=\d)

Replace by:  ~<

(^/) 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines