As an engineer I expect you to be quite familiar with cutting and pasting in MS-word. We all know that it’s always better to copy good stuff than to produce original crap. As a second nature you’ll have adopted the concept of the “global find and replace” technique to adapt your old text to its new purpose.

There is however a quite powerful technique that is less known but which will put text conversion by find-and-replace into overdrive once you master it. This method uses the so called “codes” and/or “wildcards” to define the “find” and the “replace” strings.

In the regular mode of find-and-replace you can add power by using “codes” in the “find” box as well as in the “replace” box. For instance the code ^w in the “find” box will match any consecutive combination of spaces and tabs. On the other hand, ^c in the “replace” box will paste the content of the clipboard so you can use all kinds of formatting or special characters that you could otherwise not enter directly in the “replace” box.

Using “wildcards” goes even further. In the find-and-replace dialog screen you can click on the “More” button to uncover the “search options”. One of the options in this list is “use wildcards”. If checked, it will allow the use of special expressions in the “find” box as well as in the “replace” box to enhance the capabilities of the find-and-replace action.

A simple example

Let’s suppose you want to get rid of all multiple paragraph marks in a text because you are using paragraph spacing rather than blank lines to neatly format your text. One way of doing this is to put ^p^p in the “find” box and ^p in the “replace” box (the ^p is a “code” for the paragraph mark). You then hit the “Replace All” button and keep on doing that until no more changes occur.

However, when turning on wildcards, entering (^13)@ in the “find” box will find ALL of the multiple paragraph marks in one go (even 3 or more in a row) and replace them by a single one if you put ^p in the “replace” box. The wildcard ^13 represents the paragraph mark in wildcard-format. The brackets make this a “group” of characters and the @ sign says it should occur once or more so it matches any sequence of one or more paragraph marks in one go.

Other typical uses

In a similar fashion you could replace white spaces with a single space character by finding ^w and replacing it with a space (without the use of wildcards) or by finding ( )@ with wildcards (mind the space between the brackets). The difference between the two would be that the latter only replaces series of spaces while the first one also removes tab characters. You may or may not wish to do that.

Multiple tabs by the way can be found by (^9)@. You can then choose to replace them by a single tab for instance to enable conversion of the text into a table for better formatting. Also here one replace command suffices for the whole document.

Matched groups

In case you used groups in the “find” box like <(*)>,<(*)> which would find any combination of two words separated by a comma, you can re-use the matched groups in the “replace” box like \2,\1. In fact what this last combination would do is to replace by the same words in reversed order (\2 returns the second matched group and \1 the first)

Common find and replace tasks

The following table lists some common replace tasks and the codes or wildcards required to perform them:

Wildcards Find Replace Effect
No ^l Space Removes all manual line breaks and replaces them by a space character (should be followed by removal of multiple spaces)
No ^p^w ^p Removes all spaces and tabs immediately following a paragraph mark
No ^w Space Replaces all combinations of spaces and tabs by a space character
Yes ( )@ Space Replaces all multiple spaces by a single space character (and leaves tabs alone)
Yes (^13)@ ^p Replaces all multiples paragraph marks
Yes (^9)@ ^t Replaces all multiple tabs by single tabs
Yes <(V)([0-9]@)> \1-\2 Replaces equipment number without a dash in the middle by one that has a dash
Yes <(V)-([0-9]@)> \1\2 Replaces equipment number with a dash in the middle by one without
Yes <(V)-([0-9]@)> M-\2 Replaces an equipment number starting with a “V” by one starting with an “M”
Yes <V-[0-9]@> N.A. Finds all strings like V-1, V-12, V-123, V-1234, etc, irrespective of the number of digits.
Yes <V-[0-9]{4}> N.A. Finds equipment tags of the format V-1234 (whole words only with 4 digits)
Yes <[A-Z]-[0-9]{4}> N.A. Finds any equipment tag of the format A-1234 or B-1234 or C-1234, etc (whole words only with 4 digits)

In the MS-Word help files more information can be found on additional codes and wildcards. Be advised however that the codes {n,} and {n,m} do not work. Only {n} (without the comma) does.

In case you need help on constructing wildcard search strings, look on the web for information on “regular expressions”. MS-word wildcards are a sub-set of those.

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.