Search & replace problem

  • Thread starter Thread starter Brian Clarke
  • Start date Start date
B

Brian Clarke

I have some documents with a lot of spaces in them, (because they are
reports output by some old software). They were written as text files, and I
have imported them into Word 2000. In every case where there are 2 or more
spaces together, I would like to replace that run of spaces with ONE comma.

Is there a way of doing it? The documents are each over 100 pages, so doing
it manually is out of the question.
 
For this you need wildcards. See
http://www.mvps.org/word/FAQs/General/UsingWildcards.htm (or wait for Graham
to come along and give you the exact expression you need--looks like it
might be <space>{2,} for "Find what" and a comma in "Replace with").

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Hi everybody,
1. concerning Fay's tip.
That would result in the following:
If You have 4 spaces in a row, the first 2 of them would
be replaced by 1 space. Then You have 3 left. the search
continues right from the replacement point, finds again
2 spaces and replaces them by one... But there are still
2 spaces left.
2. Use Pattern matching. Unfortunatly I got a German
version of Word, so I can't guide you perfectly, but
the search string should be (without quotation marks!)
" {2,}". You replace that, that is 2 or more occurrences
of a blank (Space) by "," (without quotation marks!),
and that's it. Note that this is, what the link, provided
by Suzanne says. Here in Germany it would be " {2;}"!
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
Many thanks to Suzanne, Helmut and Graham. I trtied <space>{2,} and it works
for me.
 
Hi Brian,

I am in your shoes quite often for I have my share of old documents. I did
make use of all those wild cards one in a while, and every time I have to
look up the exact 'wild card' and syntax from my thousand-plus page 'tome'
on Word. After all that experience, I have decided that when I need to
replace a run of spaces with a comma (or whatever character), I would use
the plain old method:

1. Press control+H to replace 4 or 5 spaces with two spaces. Press Alt+A to
do a 'Replace All'.
2. Repeat the process (ie repeatedly press the key combination Alt+A) until
a message is displayed to the effect that 0 replacement is made.
3. Press control+H to replace 3 spaces with two spaces. Press Alt+A to do a
'Replace All'.
4. (same as 2)
5. Press control+H again to replace 2 spaces with a comma.

Granted sometimes you have to press the key combinations quite a few times,
the above method is rather fast and fun for me.
 
Back
Top