Effective use of the ^& find/replace wildcard

W

WBM

I'm attempting to find certain text in Word documents
using the Find/ Replce utility with wildcards and replace
each matching text with a variant of the found text. For
example, to assemble multi-line paragraphs into a
paragraph that does not contain any line-breaks one can
ues a find expression "^13[!^t]" (w/o quotes) to find any
carriage returns not proceeded by a line indented by a tab
and replace them with a space character. However, the
first letter of each original line will be replaced by the
space since it appears in the regular expression. Any
suggestions as to how to retain the last character in the
replaced text (a general case for preserving the first or
middle charater would be better)? It seems an expression
in the "replace with" textbox using the "^&" wildcard is
warranted, but I have not yet been able effectively
manipulate its use. Thank you in advance.
 
K

Klaus Linke

Hi W,

^& re-inserts the whole matched text.
Put (brackets) around parts you want to re-use.

In your case:
Find what: ^13([!^t])
Replace with: ^32\1

I used ^32 for the space, so it's clearly visible in this post. You could
as well type a space.
The \1 inserts the stuff from the first (and in this case only) bracket.
The paragraph mark ^13 gets deleted.

The help and/or http://word.mvps.org/FAQs/General/UsingWildcards.htm has
more info.

Greetings,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top