How do I remove unwanted hyphens from some text I have copied out of a PDF into Word. The criteria is that I would like to remove any hyphen that does not have a space either to its left or right.

Currently, the words look like this because of the way they have been copied: The qui-ck brown fox- jumps o-ver the lazy dog. By the end, I only want the hyphen between fox and jumps to survive.

link|improve this question

feedback

1 Answer

up vote 2 down vote accepted

Try putting this into the Find box: [! ]-[! ] (note the spaces after the !) Make sure that "Use Wildcards" is checked.

Explanation:

[! ] Any non-space character. The [ and ] characters group patterns together while the ! negates it.

- This is the literal character -

So [! ] - [! ] is a - with non-space characters on either side.

Example character string that matches: foo-bar

Example character strings that do not match: foo- bar foo - bar foo -bar foobar, etc.

link|improve this answer
Can you please explain this? What does it do, what rules does it use? – wizlog Mar 20 at 20:22
It makes use of the wildcard support in Notepad++. Essentially, it matches any sequence of characters that follow the pattern <Any Non-space character><literal '-'><Any Non-space character> – Amazed Mar 20 at 23:44
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.