Reply To: GREP with hyphens with various numbers

Home Page / Forums / General InDesign Topics (CLOSED) / GREP with hyphens with various numbers / Reply To: GREP with hyphens with various numbers

#52163

Erick, no harm done, except it might get hard to have four people (five now) speaking through eachother on not-too related topics … 

Yikes, Eugene! That'll eat the middle digits right out of “12-34 mm”! Let's see.  “24 – 105mm” or “70-200 mm” to  “70-200mm”. Digits, some optional spaces, and a hyphen. Well, you were on the right track, but your previous efforts used the 'any' character, removing it as-you-went, no matter what it was. All it takes is a precise copy of the format, with question marks making the spaces optional:

(\d) ?- ?(\d+) ?mm

— replacing with

$1-$2mm

I prefer to use as much lookbehind and lookahead as possible, as (I think) it's faster to change as less as possible, but here I might get a bit less obvious:

(?<=\d) ?- ?(\d+) ?(?=mm)

— replacing with

-$1

This article was last modified on October 4, 2015

Comments (0)

Loading comments...