Find non consecutive repeated text using Wildcards

D

Dinosaur Mike

I need to edit a manual which contains text that may be repeated in different
sections of the word document. Is there a way to find paragraphs which have
been repeated using a wildcard code?
 
K

Klaus Linke

Dinosaur Mike said:
I need to edit a manual which contains text that may be repeated in
different sections of the word document. Is there a way to find paragraphs
which have been repeated using a wildcard code?

Sure:
For a single paragraph, a suitable wildcard expression would be [!^13]@^13
(where ^13 is a paragraph mark, using its ASCII code 13).

So to look for repeated paragraphs, you could try
^13([!^13]@^13)*\1

This should work well, except for the very first paragraph (since it doesn't
have a paragraph mark ^13 preceeding it).

\1 is looking for the first (bracketed group), here ([!^13]@^13),
* as you probably know matches arbitrary text.

This wildcard search has to do a lot of work, and may be slow on long
documents.
If you're just interested in duplicate paragraphs of a particular kind, you
may be able to speed it up by limiting the matches.
For example, by ignoring paragraphs shorter than 15 characters:
^13([!^13]{15,}^13)*\1

Be careful to collapse the selection (and go down a paragraph) before
running the search again... Else, the search will only look for duplicates
in the selected text.

The wildcard search selects everything from the original paragraph to the
duplicate.
If you want, you could write a macro that does the search, collapses the
selection to the end, and then selects only the duplicate paragraph.

Regards,
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