I want to change the spacing on citations in my document. They currently look like:

something [1]

And I want them to look like:


There are dozens of citations in my document, so I would like to use the find feature in Word to make this less tedious.

From reading this I tried to make a wildcard that would match, but it doesn't work.

Find: ([A-z]@>) (\[[0-9]*\])

Replace: \1\2

The Find doesn't work. So, I do not know if the Replace will either. What am I missing? Thanks for your help!

Edit: here is what I get when I enter ^w:

^w is not a valid special character

  • Try replacing ` ([[0-9]+])` with \1. In regex, the asterisk means zero or more, while the plus means one or more, so you’ll want to indicate that there must be a number between the brackets. (In VisualStudio, there is an option in the Find dialog to use either basic wildcards or regex, so I imagine that Word does as well.) – Synetech Mar 17 '11 at 21:58
  • 1
    I am afraid there isn't such an option for Word. It would be nice... – wdkrnls Mar 21 '11 at 18:29

Word uses special characters in search and replace. If you are just trying to remove any white space before any instance of an open square bracket you can replace ^w[ with [. ^w is Word's way of representing white space for purposes of a find.

  • Sorry, I wasn't able to get ^w to work in Word. I tried "^w" and Ctrl-w. Neither of them worked to detect whitespace. – wdkrnls Mar 20 '11 at 19:16
  • Which version of Word were you using, and did you uncheck the wildcard option? – Jason Aller Mar 20 '11 at 23:43
  • I am using Word 2007. – wdkrnls Mar 21 '11 at 18:24

IF it is acceptable to remove a single space immediately before the opener of a square bracket pair containing anything, then the following should work:

Find what:    ([ ])(\[*\])  
Replace with: \2  

SU258904 example

The Find is in two parts (i) [ ] and (ii) \[*\], with the parts separated within parentheses. It is in two parts so that, having found what we are looking for, we can replace just the second part (ie \2) - hence removing the space which is all that is the first part (ie [ ]). [The square brackets are not actually needed here but show that there is a space better than just ( ) in most fonts.]

Looking for anything is the purpose of *. Your citations are encapsulated within characters that happen to have special significance in this context (ie square brackets) so these must be 'escaped' to be taken literally. The escaping is done with a back slash. So \[ is the opener [ and \] is the closer ].

You were exceedingly close with your attempt!

Further details available here for example.

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.