03 April, 2007

Find and Replace special characters in Word

I recently had a list of items that I wanted to grab from a web page drop-down list. Of course you can't copy a drop-down list, but... you can view the source and get the list. The problem though is, "how do you remove the option tags and the value?" As you may have guessed by the title, you can do it with Word.

Here's a sample taken from News.com:

  1. Copy the list and paste it into Word.
  2. Open the Find and Replace dialog (Edit | Replace... or Ctrl + H).
  3. Click the More button and check Use wildcards.
  4. Here's the trick, as you need to use special characters. First, paste the string you want to remove in the Find what: field.
  5. For each greater than and less than character, place a backslash before it, i.e. < becomes \< .
  6. Replace the contents of the value field with an asterisk.
  7. Validate Word will be able to find the code by clicking the Find Next button -- the code should now be highlighted.
  8. Go to the Replace with: field and enter ^p. This will replace your code with a carriage return.
  9. Press the Replace button once to validate that it works as expected.
    If not, close the Find and Replace dialog and then enter ctrl+z to undo, then return to the Find and Replace dialog to correct the error.
  10. Now press Replace All button to replace all the code with a carriage return.
  11. Likely the beginning code and ending code will still exist, as they are different than the rest. Delete those two entries and you are done.
Now you should have a list from a web site's drop-down list. Obviously with this short list, you could have easily retyped the list, but for me, I just used this technique for a list that was over 600 entries long.

1 comment:

Thomi Horath said...

This hint is really usefull! I had to replace a lot of words which look like for example this: "1|[155089354]".
Actually I just wanted to delete all these entries from my word list.
So I took the find and replace tool and put to find this: "1\|\[*\]".
And it works! Word finds this! Cool, isn't it? Thank you very much!