Find and Replace blocks of text within brackets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have many documents that I need to redact/remove text that lies between [ ]
brackets and replace it the text with XX. Is there a way to do this?

EX:
blah blah blah blah blah [blah blah blah] blah blah blah.

would be replaced with -

blah blah blah blah blah [XX] blah blah blah.

Can anyone help?

Thanks,

Mike
 
Archangel said:
I have many documents that I need to redact/remove text that lies
between [ ] brackets and replace it the text with XX. Is there a way
to do this?

EX:
blah blah blah blah blah [blah blah blah] blah blah blah.

would be replaced with -

blah blah blah blah blah [XX] blah blah blah.

Can anyone help?

Thanks,

Mike

See http://word.mvps.org/FAQs/General/UsingWildcards.htm.

The Find expression should be
(\[)(*)(\])

The Replace expression should be
\1XX\3

Don't forget to click More and check the "Use wildcards" box. Then click
Replace All.
 
Although Jay's suggestion works perfectly, for the sake of completeness, the
centre brackets are actually superfluous
(\[)*(\])
replace with
\1text\2
will work just as well
And if the square brackets are no longer required neither are the round
brackets so in those circumstances, replace the string
\[*\]
with
text

An updated version of the web page Jay has linked is available at
http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Jay said:
Archangel said:
I have many documents that I need to redact/remove text that lies
between [ ] brackets and replace it the text with XX. Is there a way
to do this?

EX:
blah blah blah blah blah [blah blah blah] blah blah blah.

would be replaced with -

blah blah blah blah blah [XX] blah blah blah.

Can anyone help?

Thanks,

Mike

See http://word.mvps.org/FAQs/General/UsingWildcards.htm.

The Find expression should be
(\[)(*)(\])

The Replace expression should be
\1XX\3

Don't forget to click More and check the "Use wildcards" box. Then
click Replace All.
 
Back
Top