Find only repeated words
Thread poster: Samuel Murray
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 17:05
Member (2006)
English to Afrikaans
+ ...
May 22, 2018

Hello everyone

Using MS Word, is there a search string or a macro that will find and/or highlight all repeated words? I know that repeated words are flagged during spell-check but I want to look for ONLY repeated words. By "repeated words" I mean words that repeat next to each other, e.g. "the" in "paris in the the spring".

Alternatively, what would the search strings be in regular expressions in a regex capable text editor?

Thanks
Samuel


 
Thomas T. Frost
Thomas T. Frost  Identity Verified
Portugal
Local time: 16:05
Danish to English
+ ...
I would use Excel May 22, 2018

I would split the whole Word file into one word per line (using the Replace function: " " to "^p" to change blanks to line breaks), then copy and paste the whole thing into Excel, where you can use a formula such as "if(A1=A2;"REPEATED";"") and copy it down.

You may need to remove some blank lines first. You could start by numbering all the Excel lines (use copy series down). Then you can sort on the text column, remove the blank lines, then sort again on the line numbers to get the
... See more
I would split the whole Word file into one word per line (using the Replace function: " " to "^p" to change blanks to line breaks), then copy and paste the whole thing into Excel, where you can use a formula such as "if(A1=A2;"REPEATED";"") and copy it down.

You may need to remove some blank lines first. You could start by numbering all the Excel lines (use copy series down). Then you can sort on the text column, remove the blank lines, then sort again on the line numbers to get the text back in the original order.

Does it make sense?
Collapse


 
Philip Lees
Philip Lees  Identity Verified
Greece
Local time: 18:05
Greek to English
Regex for repeats May 23, 2018

Samuel Murray wrote:

Alternatively, what would the search strings be in regular expressions in a regex capable text editor?



This works in perl:

$_ = 'Paris in the the spring is a wonderful wonderful time';

print "$1\n" while /([a-zA-Z]{2,})\s+\1/g;

The output is:

the
wonderful

This only catches repeats of groups of at least two alphabetical characters, separated by at least one space.

You may be able to tweak it if it's not quite right.

The $1 represents the matched string and in contexts other than perl may need to be replaced by \1, which also represents the repeated part in the regex.

The g flag at the end forces it to search the entire string for matches, rather than returning the first match over and over again.


 
Philip Lees
Philip Lees  Identity Verified
Greece
Local time: 18:05
Greek to English
And in Word May 23, 2018

Samuel Murray wrote:

Using MS Word, is there a search string or a macro that will find and/or highlight all repeated words?


Well whaddyaknow? My regex also works in Word with a few tweaks.

Search for:

([a-zA-Z]{2,}) @\1

with "Use wildcards" checked.

I didn't know Word's search function could handle repeat matches like that.


 
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 17:05
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Yes, pleasant surprise May 23, 2018

Philip Lees wrote:
Well whaddyaknow? My regex also works in Word with a few tweaks.
I didn't know Word's search function could handle repeat matches like that.


(-:


 
Philip Lees
Philip Lees  Identity Verified
Greece
Local time: 18:05
Greek to English
And now ... (off topic) May 23, 2018

Samuel Murray wrote:

(-:


If you think that's cute, have a look at this:

http://neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Find only repeated words






TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »
Wordfast Pro
Translation Memory Software for Any Platform

Exclusive discount for ProZ.com users! Save over 13% when purchasing Wordfast Pro through ProZ.com. Wordfast is the world's #1 provider of platform-independent Translation Memory software. Consistently ranked the most user-friendly and highest value

Buy now! »