1 person found this helpful
I think it's replace with $1.
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.
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
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?
Thanks, although this appeared to pick up any number followed by a comma, not just those preceded by a dollar sign. I might have messed up the syntax though as yours and Vandy's response came in al most simultaneously and I was keen to try both as quickly as possible. Same question goes for you though, why does your find/change work with the change to as "$1" when mine simply changed the found text to the actual strong "$1"?
Now I'm thinking I somehow did something wrong when using your method. The two posts below suggested changing to "$1" and it worked in both instances, but not yours. I suspect the error might be at my end! Thanks.
It's easier to do this:
Find what: (?<=\$\d\d),
Change to: nothing (i.e. leave the field empty)
This is more efficient as you needn't use references. (?<=\$\d\d) is a lookbehind, so in effect the Find what expression says "if a comma is preceded by $ and two digits, then delete the comma."
If you use CS6 8.0.0 or earlier, by the way, you'll have problems with \$ as it will find only the first $. Better use [$] or \x24 to find dollar symbols.
Thanks very much for your help, that's great. Out of interest, can the find statement be modified to be broader, say if a comma is preceded by a $ and any number of digits? Is it (?<=\$\d+),
I'm really struggling to get to grips with how GREP statements work. Thanks again.
No, unfortunately lookbehinds don't work with variable-length strings. That's the case with all GREP implemantations, not just InDesign's. You can sort of get around it by using or-constructs, but they soon become unmanageable. Here's an example (split and indented just for clarity, you would need to write all this on one line):
This one says "if a comma is preceded by $ and a digit OR by $ and two digits OR by $ and three digits, then . . ." As you understand, if you need to allow up to six or seven digits, possibly thousand separators too, then lookbehinds become unpracticable.
>I'm really struggling to get to grips with how GREP statements work.
Thanks for your reply, I really appreciate it. Will definitely check out that book.