Can Word Solve Its Own HTML Problem? You Betcha!
By Robert Delwood
A Lead API Documentation Writer[Home] [Writing samples] [LinkedIn]
Search, along with find and replace, are ubiquitous tools that no one thinks to talk about often. After all, we know how to use them, right? However, over the years they have become powerful text editing tools. We are in a market that technical writers and programmer-writers cannot afford to overlook the few tools we have. In this case, these are Microsoft Word’s wildcard search and wildcard replace features.
This article is not a tutorial about wildcards. A short article like this one couldn’t do justice to this topic. Instead, it is a demonstration for what wildcards can do. If these look promising, you are encouraged to investigate further. There are suggestions at the end of the article.
Wildcard search allows you to find patterns rather than exact text. We’re all used to the conventional search that specifies exact text, perhaps the word properties in a document. However, there are cases when you do not know exactly what you’re looking for. This could be color/colour, or any form of Jeffery/Jeffeory/Geffrey. Yes, you can find all of those within a set in a single search. Wildcard replace allows the found pattern, or part of the pattern, to be used in the replacement. The real power is using this with code, such as HTML or XML. Writers are increasingly expected to fix code.
Word can save a document as HTML but produces some of the worst HTML code. So bad in fact, some companies discourage Word-generated HTML files. Ironically, you can use Word to clean up its own HTML.
First, prepare a document.
The bottom line is that the code can be clean as you need it and won’t take long by using wildcard replacement.
Making these changes requires the following set up:
The asterisk (*) is a wildcard for any number of characters. If fact, you have to tell it when to start and/or stop. Brackets are a strange case. They are used to create expressions. However, we need to use them as literal brackets that form the style tag. For that, the backslash indicates to use the immediately following character as a literal.
With these notations, the expression \ comes to mean a literal open bracket, the literal span, any number of characters, and until it gets to the first literal close bracket.
The wildcard asterisk picks up all the elements inside the span tag. In other words, we don’t care what other elements there are inside. We’ll select them all just to then delete them.
Click Find Next to test the expressions to make sure they’re finding what you want.
Text replacement uses the values in Replace with text box with what is found. The example uses either nothing (there is no value), or a single space.
This is only an example of what Word’s wildcards can do. Use the following links to learn more, and continue to search the Internet for other sites and examples.