The Editors' Weekly
Official blog of Canada's national editorial association
The Editors' Weekly
Navigation
  • About the Blog
  • Contact Us
  • Articles en français
  • editors.ca
  • reviseurs.ca
You are here: Home › Aaron Dalton › Wildcards and Regular Expressions
← English Editing in Quebec: Linguistic Interference During COVID-19
Sex, Gender and Pronouns: Using the Correct Pronouns for Inclusiveness →

Wildcards and Regular Expressions

November 10, 2020 | Filed under: Aaron Dalton and tagged with: Aaron Dalton, editing tools, software, technology, Word

Recently, I’ve seen some problems involving global text edits that were easily solved with Microsoft Word’s Advanced Find and Replace feature. Spending some time learning the ins and outs of this feature will more than pay off when you’re able to do something in minutes that would take you hours to do manually.

Find and replace

Let’s say you want to change all your footnotes from superscript numbers to normal numbers enclosed in square brackets.

How to use the Find and Replace feature to change all your footnotes from superscript numbers to normal numbers enclosed in square brackets.

The caret combined with a lowercase “f” (^f) will find all footnote markers, be they symbols, letters or numbers. And the caret combined with the ampersand (^&) represents whatever text was matched by the Find what clause. Click Special to bring up a list of other special wildcard characters ([]{}<>()-@?!*\) and other special characters (tab, caret, em dash, etc.) that you can search for.

Here’s another example that will lead into the next topic. Let’s say you need to code all your italic text using HTML.

How to use the Find and Replace feature to code all your italic text using HTML.

Again, we see the usefulness of the caret and ampersand combined (^&). And we also see that we can leave the Find what field blank to search just for formatting! Magically, all our italic text becomes <i>italic</i>.

Wildcards

To convert that coded text back into italic, things get a little more complicated. If you check the Use wildcards checkbox, you’ll see the options available in Special have changed. What this unlocks is a subset of the language called “regular expressions” (we’re getting there). The feature that I use the most is the ability to get more granular than simply ^&.

If you check the Use wildcards checkbox in the Find and Replace feature, you'll see new options in Special.

First, we enter the codes in the Find what field. Because angle brackets (< >) have a special meaning, we must “escape” the brackets by inserting a backslash in front of them. In the middle, we enter an asterisk enclosed in parentheses (*). The asterisk allows you to search for all characters between those codes, and the parentheses groups those characters for later reference.

We reference that group of characters in the Replace with field. We can’t just enter ^& because that would keep and italicize the codes. All we want to italicize are those characters between them. Because there’s only one set of parentheses, we simply insert \1, referencing the first (or only) group in the Find what field. But if you have multiple sets of parentheses, you reference them with \2, \3, and so on.

Note: Wildcard searches will sometimes not work properly if Track Changes is active.

Regular expressions

Frustratingly, Word does not implement the full power of the language known as “regular expressions.” For that, you have to turn to other software. If you’re working in Adobe InDesign, then you’re in luck. Its regular expression support is robust. Otherwise, I have often copied text into a text editor that supports regular expressions to do some work (I personally prefer Visual Studio Code), and then I’ve moved the text back into Word. (I do this with tables a lot.)

There are many things you can do using regular expressions that you can’t do in Word. The most invaluable would be positive and negative lookaheads and lookbehinds.

Consider the following idiosyncratic citation style:

O’Connell, S.C. (1994): Geological history of the Peace River Arch; in Geological atlas of the Western Canada Sedimentary Basin, G.D. Mossop and I. Shetsen (comp.), Canadian Society of Petroleum Geologists and Alberta Research Council, p. 431–438 [May 2016].

See that italic “in”? Positive lookbehinds to the rescue: (?<=\;\ )in matches just the word “in” if and only if it is preceded by a semicolon and a space. Just apply the formatting.

More information

For more information, simply search for terms such as “msword wildcards” and “regular expression tutorial.” Here are a few resources to start with:

  • WordMVP wildcard tutorial with examples: https://wordmvp.com/FAQs/General/UsingWildcards.htm
  • A regular expression primer: https://ryanstutorials.net/regular-expressions-tutorial/
  • Real-time regular expression tester: https://regexr.com/
  • Editing software packages that include features to simplify global edits

Any tips, tricks or special tools that you use? Please share below!

___

Previous post from Aaron Dalton: Learning from History

The Editors’ Weekly is the official blog of Editors Canada. Contact us.

Did you like this article? Share it with your friends!

Tweet

Written by Aaron Dalton

Through an eclectic career that spanned hospitality, software localization, computer programming, and musicology, Aaron learned firsthand the power of audience-centred communication. He currently works for the Alberta Energy Regulator as an editor and plain language evangelist, where he develops and delivers staff training on effective writing.

Visit my Website Follow me on Twitter
← English Editing in Quebec: Linguistic Interference During COVID-19
Sex, Gender and Pronouns: Using the Correct Pronouns for Inclusiveness →

What we’re talking about

Aaron Dalton author-editor relationship authors book editors book publishing business practices communication copy editing editing editing tools editor editor's role editor advice editorial skills editors editors at work Editors Canada conference français freelance editing freelance editors freelancing French grammar interview James Harbeck language linguistics Linguistics Frankly Marianne Grier marketing networking plain language professional development proofreading publishing Rosemary Shipton révision style translation usage Wasted Words Wilf Popoff word choice writers writing

Email subscriptions

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,041 other subscribers

Most recent posts

  • “Brag docs”: An Aide-mémoire
  • Resumé Writing vs. Resumé Editing: What Do Resumé Writers Do?
  • Happy Holidays 2022
  • Freelance Tips from an Editor with ADHD, Part 1
  • Combining Careers, Part 1: Vocational Discernment

Archives by month

By author

Follow Us Online

Facebook  Twitter  Flickr  RSS Feed

www.editors.ca

The Editors' Weekly is the blog of Editors Canada.

Report an error or a typo

Email us at blog [at] editors.ca

© 2023 The Editors' Weekly

Powered by One Designs