How to Format Your Essay with Advanced Pattern Matching

By Joseph Wallace

Formatting essays can be tedious work. Even though there is no substitute for careful reading, there are some ways to streamline the process. Mistakes in formatting can be complicated to resolve, but if you know the basics of how to look for patterns in your text, you can customize solutions for your editing and formatting problems.

I discuss here how to use “regular expressions” in Microsoft Word to rearrange and replace elements of your essay. This post will be useful for copyeditors tasked with making sure manuscripts conform to a certain style (I’ll be discussing MLA style, of course). But it will also be helpful for writers who need to change a manuscript from one style to another or to make sure they have all elements of the manuscript in place.

Let’s say that an author cites an essay from a scholarly journal as follows and that this format is used for all the essays cited (the example is adapted from the MLA Handbook [28]):

Goldman, Anne. “Questions of Transport: Reading Primo Levi Reading Dante.” The Georgia Review, vol. 64, no. 1 (2010): 69–88.

If the essay is meant to be in MLA style, this entry in the works-cited list is not correct.

  • The date should not be enclosed in parentheses.
  • The date should also not be followed by a colon.
  • A comma should follow “no. 1.”  
  • The page range should be preceded by “pp.”

The entry should appear as follows:

Goldman, Anne. “Questions of Transport: Reading Primo Levi Reading Dante.” The Georgia Review, vol. 64, no. 1, 2010, pp. 69–88.

It would be time-consuming, and boring, to manually change all the citations, especially if there were a lot of them. But if you know how to match patterns using wildcard characters, you can do this very quickly.

How to Use Pattern Matching

Go to Word’s “Find and Replace” function. You should see both a “Find what:” and a “Replace with:” box. Look at the bottom and click “More >>,” then check the “Use wildcards” box. Now type the following into the “Find what:” box (note that there should be a space entered at the beginning):


Type this into the “Replace with:” box:

, \1, pp.

Now click “Replace All.” Your citations have all been fixed.

The patterns you typed into the “Find what:” box and the “Replace with:” box were actually “regular expressions.” As you can see, regular expressions are typically formed by combining normal text (like “pp.”) with wildcard characters, which are characters that can represent different kinds of characters.

Let’s go back to the pattern in the “Find what:” box, and I will explain each portion.

                You need to begin with an empty space (just press the space bar once), because you want that space included in the pattern to be replaced. You may have noticed that in the original there is no comma after “no. 1,” and we will need one in the final version.

\(            This means that you want to search for an opening parenthesis. After you clicked “Use wildcards,” the parenthesis became a special character. The back slash “escapes” special characters. So you are telling Word that you want a parenthesis character itself.

(              Now you typed an unescaped parenthesis. This is a special character that indicates the beginning of an “expression.” Using expressions allows you to capture everything inside the parentheses and use it in the replacement pattern.

[0-9]      The straight brackets mean “any character in range.” This pattern matches any number between 0 and 9. The pattern “[a-z]” would match any lowercase letter.

{4}          The curly brackets indicate the number of times you need the preceding character or pattern to repeat. In this case, we are only interested in four numbers in a row (because we are looking for years). So [0-9]{4} means “find any four numbers in a row.”

)              Another unescaped parenthesis indicates that we are done capturing an expression. In this case the expression will be the year contained in your essay citation.

\)            Here you have escaped the final parenthesis, meaning that you are only interested in four numbers in a row if they are contained in parentheses.

:               Finally you typed a colon, meaning you want the year that is enclosed in parentheses to be followed by a colon. This pattern will only find four numbers in a row that are enclosed in parentheses and followed by a colon.

The “Replace with:” box is a little simpler.

,               First you need a comma followed by a space. This will insert the comma after “no. 1” and then maintain the space between it and the year that follows.

\1            This is known as a “back reference.” It refers back to the first (hence the “1”) expression that you captured in your “Find what:” pattern. In this case, it will be the four numbers in a row—in other words, the year.

, pp.       This simply means that you want the year to be followed by a comma, a space, and then “pp.”

So your pattern will remove the parentheses and colon, and then it will insert a comma, space, and “pp.” And that’s it. The whole process is fast, and you don’t have to worry about making mistakes while you are keying in the changes.

A Diverse Skill

What’s great about knowing how to use patterns like these is that they can deal with almost any formatting problem you encounter. They also allow you to be creative. For example, what if, in the citation above, the year had been preceded by a month? So the entry might look as follows:

Goldman, Anne. “Questions of Transport: Reading Primo Levi Reading Dante.” The Georgia Review, vol. 64, no. 1 (Jan. 2010): 69–88.


Goldman, Anne. “Questions of Transport: Reading Primo Levi Reading Dante.” The Georgia Review, vol. 64, no. 1 (June 2010): 69–88.

The original pattern we wrote would not work because it would not recognize the characters that precede the year. We can adjust our pattern as follows:

 \(([A-Z]*{2,4} [0-9]{4})\):

Here we have added a character range, “[A-Z],” which looks for one capital letter. Then we have added a wildcard character “*,” which means “any character whatsoever.” And finally we specified that we are only interested in 2-4 of the “any character whatsoever” characters, because all the potential variations of months and their abbreviations are between 2 and 4 characters, not including the initial capital (e.g., “May,” “Apr.,” “June,” “Sept.”). Also note the space between “{2,4}” and “[0-9],” which represents the space between month and year in the text. The “Replace with:” pattern remains the same.

Where to Find More Information

Here’s Microsoft’s Web site explaining how to use wildcard characters in find-and-replace patterns:

Microsoft’s Find and Replace Instructions

This site explains all the symbols and also has an example of how to work with regular expressions.

A Final Word

Regular expressions take some time to learn, but that time is well spent. It will pay off in saved time later on when you need to make extensive changes to an essay. The examples I discuss here are relatively basic and straightforward, but the possibilities are endless. Once you have the pattern you want, you can do anything you like to all its matches in the document. You can apply a predefined style, change the format, or apply highlighting, just to name a few options.

Work Cited

MLA Handbook. 8th ed., Modern Language Association of America, 2016.

Published 19 December 2018

Join the Conversation

We invite you to comment on this post. Comments are moderated and subject to the terms of service.

If you have a question about MLA style, ask us! Questions submitted through this comment form will not be answered.

Fields marked with * are required.

Your e-mail address will not be published.

Get MLA Style News from The Source

Be the first to read new posts and updates about MLA style.

The Source Sign-up - Style Center Footer

Skip to toolbar