1

I am having a problem with a regex find and replace in Word 2010 (Windows 7).

I want to convert reference citation numbers in parentheses to the same numbers in brackets. For example, (20-23) should become [20-23], (19, 20) should become [19, 20].

I have the following Find what: \(([0-9], -]*)\) and Replace with: [\1]

But this puts the found expression before the brackets, instead of within. (20-23) becomes 20-23[], (19, 20) becomes 19, 20[]

Can anyone tell me the correct syntax for this replace?

0

The code you pasted had an extra bracket, I'm not sure how it would have done anything but error...

\(([0-9, -]*)\)

works fine.

  • Thanks. That's one of those things you can stare at for hours and never see. Would have helped if Word had said the Find pattern was invalid (but I guess it's not invalid). I still don't see why it produced the result it did, as the parentheses defining the expression which should go into \1 are correct, and \1 is in the correct place in the replace text – timbp May 6 '14 at 22:50
0

try this

\50(\d+-\d+)\51

replace for [\1]

and tell me if it works

  • Doesn't work: "The Find What text contains a Pattern Match expression which is not valid". – timbp May 3 '14 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.