Wow! thanks for the quick response. That totally worked, thank you so much, you have saved me hours of work!
1 person found this helpful
GREP is unable to find 'sequential' numbers, but if you want to remove "all numbers between square brackets", that can be done with this:
(and replace with nothing)
A little break-down: the characters [ and ] are special in a GREP expression -- they indicate a custom group of characters. For example, the sequence [0-9] will search for a single digit, from "0" to "9", and the sequence [a-fh-zABC] will search for a single character from the set "a to f, h to z, or A or B or C". Because of this special behavior, if you want to search for a literal [ or ], you have to add a backslash, which instructs GREP to 'escape' the default meaning. That's why my query says "\[" and "\]".
The sequence [0-9] will search for any single digit, but as it is such a popular range, it has a code of its own: \d ('d' for 'digit'). Similar shortcuts for character ranges are \u ("uppercase") and \l ("lowercase"), \w ("word character", i.e., any alphabetic or numeric character), and \s (any white space character). The inverse is also possible: \D will match every and any character except a single digit.
The + indicates that the previous code (which is the single character group code for digits) may be repeated; it stands for 1 or more. Two similar codes are * -- 0 or more, i.e., "only if it's there" -- and ? -- zero or 1 time.
With a few GREP codes, combinable in literally endless different ways, you can efficiently search for a variety of text. It seems just about everything is possible, one way or another ... well, expect for searching for sequential numbers, as GREP cannot count!
If you want to know more about it, Peter Kahrel's O'Reilly Shortcut "GREP In InDesign" is considered the best guide. Don't be put off by the "CS3/CS4" in the title; this has hardly changed, and Peter even updated the latest version to include CS5-specifics as well.
Thanks for the breakdown -extremely useful. Much appreciated