Repeated consecutive words

  • Thread starter E. Omar Troccoli K.
  • Start date
E

E. Omar Troccoli K.

En blanco



HI:



I need a macro that find any repeated consecutive word in a Word document. I'm working with large document and sometimes it have (wrong) consecutive repeated words, and sometimes it pass the manual revision and the final document goes with that repeated words.

I don't need that the macro eliminates the word, just mark it and we decide if eliminate it or not.

Any help will be so much apreciated.



Thanks in advance,





Omar
 
K

Klaus Linke

Omar said:
I need a macro that find any repeated consecutive word in a Word
document. [...]


Greg Maxey said:
The spell checker flags repeated words.


Or you could try "Edit > Find", with ""Use wildcards" checked, and
Find what: (<* ){2}

This would match one or more repeated words, but only if they are followed
by spaces in both instances.
So it would match
"rose is a rose is a"
in
"A rose is a rose is a rose".

(Wildcard searches are always case sensitive)

Matching only repeated single words, and even if one of them is followed by
punctuation, would be harder.
As a first try:
Find what: (<[! ]@>)[.,;/\!\? ]@\1

([! ] matches any character except a space, and "<" and ">" match only at
the start and end of a word; so "<[! ]@>" should match some word.
"[.,;/\!\? ]@" is a list of punctuation characters (where "!" and "?" had to
be "escaped" with a \backslash since they have a special meaning in wildcard
searches).
"\1" repeats the first (bracketed group); so it should match if the word
matched with "(<[! ]@>)" appears once more.

Greetings,
Klaus
 
E

E. Omar Troccoli K.

HI, KLAUS:


First, thanks for your answer. I will look that and make it run as you
indicate.

Second, I see that you use "Edit", "Find" and so on, and use a string of
characters without any sense for me and for regular users, and the new
question that I have is how can I take a full list of that sequences for
global use, or, in other words, how can I "traduce" my needs to this
particular code.

Any list of sequences or simillar will be so apreciated.

Thank you, again.

Omar
From Argentina





Klaus Linke said:
Omar said:
I need a macro that find any repeated consecutive word in a Word
document. [...]


Greg Maxey said:
The spell checker flags repeated words.


Or you could try "Edit > Find", with ""Use wildcards" checked, and
Find what: (<* ){2}

This would match one or more repeated words, but only if they are followed
by spaces in both instances.
So it would match
"rose is a rose is a"
in
"A rose is a rose is a rose".

(Wildcard searches are always case sensitive)

Matching only repeated single words, and even if one of them is followed by
punctuation, would be harder.
As a first try:
Find what: (<[! ]@>)[.,;/\!\? ]@\1

([! ] matches any character except a space, and "<" and ">" match only at
the start and end of a word; so "<[! ]@>" should match some word.
"[.,;/\!\? ]@" is a list of punctuation characters (where "!" and "?" had to
be "escaped" with a \backslash since they have a special meaning in wildcard
searches).
"\1" repeats the first (bracketed group); so it should match if the word
matched with "(<[! ]@>)" appears once more.

Greetings,
Klaus
 
K

Klaus Linke

Hi Omar,

Sorry, I was a bit terse.

You can find a bit of help on wildcard searches in Word's help ("Search by
using wildcards"). To get you started with a couple of examples, you may
find the article http://www.mvps.org/word/FAQs/General/UsingWildcards.htm
helpful.

To take the expression I gave apart:

Find what: (<* ){2}

"<" looks for the beginning of a word.
"* " matches any following text (* = any string of arbitrary characters),
ending in a space.
By putting this in brackets "(<* )", you can then search for repetitions of
the bracketed expression.
So "(<* ){2}" will match one or more words ending in a space if they are
repeated 2 times.

Greetings,
Klaus


E. Omar Troccoli K. said:
HI, KLAUS:


First, thanks for your answer. I will look that and make it run as you
indicate.

Second, I see that you use "Edit", "Find" and so on, and use a string of
characters without any sense for me and for regular users, and the new
question that I have is how can I take a full list of that sequences for
global use, or, in other words, how can I "traduce" my needs to this
particular code.

Any list of sequences or simillar will be so apreciated.

Thank you, again.

Omar
From Argentina





Klaus Linke said:
Omar said:
I need a macro that find any repeated consecutive word in a Word
document. [...]


Greg Maxey said:
The spell checker flags repeated words.


Or you could try "Edit > Find", with ""Use wildcards" checked, and
Find what: (<* ){2}

This would match one or more repeated words, but only if they are followed
by spaces in both instances.
So it would match
"rose is a rose is a"
in
"A rose is a rose is a rose".

(Wildcard searches are always case sensitive)

Matching only repeated single words, and even if one of them is followed by
punctuation, would be harder.
As a first try:
Find what: (<[! ]@>)[.,;/\!\? ]@\1

([! ] matches any character except a space, and "<" and ">" match only at
the start and end of a word; so "<[! ]@>" should match some word.
"[.,;/\!\? ]@" is a list of punctuation characters (where "!" and "?"
had
to
be "escaped" with a \backslash since they have a special meaning in wildcard
searches).
"\1" repeats the first (bracketed group); so it should match if the word
matched with "(<[! ]@>)" appears once more.

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