Microsoft Word 2010 regex replace

08
2014-07
  • timbp

    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?

  • Answers
  • Madball73

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

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

    works fine.

  • Sirius_Black

    try this

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

    replace for [\1]

    and tell me if it works


  • Related Question

    Find matches to regex '[^,] which' in MS Word
  • JustinJDavies

    I wish to Find instances of the substring [^,] which — the word which preceded by a space '' that is preceded by a character that is not a comma [^,]. Can this be done?

    The query [,] which works fine but the negation breaks the regex. Is there a special syntax in MS Word or is this not available within the Find/Replace dialogue?

    When I try this query I get the Warning dialogue, ^ is not a valid special character for the Find What box or is not supported when the Use Wildcards check box is selected


  • Related Answers
  • Aluísio A. S. G.

    Use [!,]; from this article:

    t[!a-m]ck finds "tock" and "tuck," but not "tack" or "tick."