Remove words broken with hyphens; keep true hyphenated words (1 Viewer)

sxschech

Registered User.
Local time
Today, 08:10
Joined
Mar 2, 2010
Messages
791
I imported a plain text file and discovered that some words have hyphens that shouldn't be there. Perhaps due to someone along the way copied word data and pasted to a plain text file. I ended up using a text editor and doing a manual find and replace for each file in order to correct the issue. Does anyone have an idea if this could be automated for future situations?

One could not simply do a find and replace because there are words that legitimately should be hyphenated. Or would it require building a list of hyphenating words and end up being more time consuming than manually reviewing each instance of a find and replace? Field in question is Long Text.

Remove hyphen:
re-search ==> research

Keep hyphen:
interest-free ==> interest-free
 

isladogs

MVP / VIP
Local time
Today, 15:10
Joined
Jan 14, 2017
Messages
18,186
Why not run a spell check on all imported text?
It should pick up many of the spurious words like re-search
 

sxschech

Registered User.
Local time
Today, 08:10
Joined
Mar 2, 2010
Messages
791
I'll give that a try next time, since automation may not be viable.
 

isladogs

MVP / VIP
Local time
Today, 15:10
Joined
Jan 14, 2017
Messages
18,186
Actually thinking about it, you could run a loop on each hyphenated word in turn as follows
a) remove hyphen from the word
b) spell check the word created
If it's a valid word, keep the change
If not, restore the hyphen
c) next

That makes more sense than spell checking before treating the hyphen
 

Users who are viewing this thread

Top Bottom