Replace Parentheses Around Wildcard References in Microsoft Word
Question details
Replace parentheses around references such as (p456) with square brackets while preserving the reference text.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- The user wants to change reference punctuation using Word's wildcard Find and Replace feature.
- Observed behavior
- References such as (p456) should become [p456], with the letter and digits unchanged.
Check whether the references contain exactly three digits or a variable number of digits. Open the document in Word and identify a few examples to test the pattern.
Use Word wildcards to replace parentheses with square brackets
Use this method to preserve each reference while changing its surrounding punctuation.
The backslashes make Word treat the outer parentheses as literal characters. The inner parentheses capture the reference text, which the replacement inserts using \1.
In Word, open Home > Replace, or press Ctrl+H where supported.
Select More if needed, then check Use wildcards.
In Find what, enter \((p[0-9]{3})\) for references with exactly three digits. For one or more digits, enter \((p[0-9]@)\) instead.
In Replace with, enter [\1]. This keeps the captured reference and surrounds it with square brackets.
Select Find Next and Replace to check a match, then use Replace All if the results are correct.

Edit Word documents and references with WPS Writer
WPS Office is a free, lightweight alternative for editing documents in a familiar interface. Open compatible Word files to continue working with minimal disruption; use Microsoft Word for the wildcard syntax described above.

Frequently Asked Questions
How do I match references with any number of digits?
With Use wildcards checked in Word's Replace dialog, enter \((p[0-9]@)\) in Find what. The @ matches one or more digits.
What does \1 mean in the replacement?
In Replace with, \1 inserts the text captured by the first group of parentheses in the wildcard pattern. Enter [\1] to put square brackets around that text.
Why are the outer parentheses preceded by backslashes?
In Word wildcard searches, parentheses normally mark a group. The backslashes in \( and \) make Word search for literal parentheses around the reference.
Will the three-digit pattern match (p4567)?
No. The pattern \((p[0-9]{3})\) requires exactly three digits between p and the closing parenthesis. Use \((p[0-9]@)\) for one or more digits.




