Skip to main content
Known Participant
December 14, 2012
Answered

GREP find/change problem

  • December 14, 2012
  • 2 replies
  • 4196 views

Hi, am trying to execute InDesign's default find/change AppleScript script to fix many formatting issues in a large document. One of them is occurences of a two-digit dollar figure followed by a comma (eg. "$10,") that needs to be changed to have no comma.

Using GREP I can pick it up by finding "\$\d\d," but when I replace it with "\$\d\d" I get the actual string "\$\d\d". IE. "$10," becomes "\$\d\d" rather than "$10". Am I misundersting how the 'change' part of GREP works? Can any one advise?

FYI the line in the find/change support .txt doc is:

grep{find what:"\\$\\d\\d,"}{change to:"\\$\\d\\d"}{include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}Remove commas after prices.

...which includes extra backslashes to escape the backslashes that are part of the GREP expression.

Any help much appreciated!

Thanks.

This topic has been closed for replies.
Correct answer Sajeev Sridharan

In Grep Pallette, use the below syntax to find  two or multiple digit dollar figure followed by a comma text,

Find what:     (\$\d+),

Change to:     $1

Vandy

2 replies

Sajeev SridharanCorrect answer
Legend
December 14, 2012

In Grep Pallette, use the below syntax to find  two or multiple digit dollar figure followed by a comma text,

Find what:     (\$\d+),

Change to:     $1

Vandy

Known Participant
December 14, 2012

Thanks, that worked perfectly. But here's what I don't understand: when I did change "\$\d\d," to "$1" it just replaced with the actual string "$1", but when I used your method, it worked fine. Apart from the difference in the 'find what' string, what makes your method work?

Larry G. Schneider
Community Expert
Community Expert
December 14, 2012

I think it's replace with $1.

Known Participant
December 14, 2012

Thanks for your reply, but that replaces the found text with the string "$1." or "$1" (not sure if the full stop was meant to be part of the string, but the result is the same). Same outcome using the find/change script or the find/change dialog within InDesign.

Known Participant
December 14, 2012

Hi Luke....,

see the screen shot & try ....

thanks

shil...