Posts Tagged ‘wildcards’


Word: Find text between chevron arrows and highlight it

May 26, 2023

Jefferson asked how he could use a wildcard search to find text between ‘chevron’ arrows, i.e. the less than (<) and greater than (>) symbols on the keyboard above the comma and period keys.

I wasn’t sure what he wanted to do with that text once found—bold it, italicise it, highlight it, etc.—so this post shows you how to highlight it. If you want to do something else, then you’d change the Font setting at Step 8 below.

NOTE: This find/replace finds ALL words between a matching set of < and > symbols, so if you only use one (say, for less than) and not the other for several pages, then all the text in the pages in between will be highlighted.

  1. Before you start, select a highlight colour from the Home tab on the ribbon (this is essential if you’re intending to highlight the text found).
  2. Press Ctrl+h to open the Find and Replace window.
  3. Click More.
  4. Select the Use wildcards checkbox.
  5. In the Find field, type: (\<)(*)(\>)
  6. In the Replace field, type: \1\2\3
  7. At the bottom of the window, click Format.
  8. Select Highlight. (If you want bold or italic, select Font instead, then Bold or Italic).
  9. Check that the formatting you want is shown BELOW the Replace field (see screenshot).
  10. Click Find Next then Replace for each one found (ONLY press Replace All if you are absolutely certain that every opening chevron arrow has a closing one, and that there are no mathematical uses for the chevrons).

How this works

  • Chevron arrows are special characters in a wildcard search so they must be ‘escaped’ to act as chevrons—you do this by placing a \ immediately before the special character, so for each you would write them as \< and \>
  • Any characters and any number of characters is expressed using an asterisk  *
  • The parentheses separate each part of the Find, so (\<) looks for an opening chevron, then (*) looks for ANY and ALL characters after the opening chevron, and (\>) looks for the closing chevron. In other words, find anything between an opening and closing chevron, whether it’s a single character or a bunch of words.
  • In the Replace, the \1\2\3 tell Word to replace the first, second and third parts of the Find with themselves; i.e. make no change.
  • The formatting under the Replace field tells Word to format the replace string with the formatting selected (i.e. in this case, highlight the original words and the chevrons in the highlight colour selected in Step 1 in this example).

Word: Replace ‘to’ in a number range with a dash

March 26, 2023

Pam asked if I could help her with a wildcard search for replacing the ‘to’ in a number range (e.g. 1.65 to 2.30) with a dash (in this case, she wanted a dash (also known as a hyphen—the one on the top of a keyboard), not an en dash, which would be typical for a number range). She PROMISED she wouldn’t do ‘replace all’, and if you’re doing this, please don’t use ‘replace all’ as you may change some things that aren’t number ranges (e.g. They each gave $25 to 10 people).

These instructions are for Word for Windows; Word for Mac should be the same once you get to its Find and Replace window:

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click More.
  3. Select the Use wildcards checkbox.
  4. In the Find, type: ([0-9])( to )([0-9]) 
    (NOTE: There is a single space either side of the ‘to’)
  5. In the Replace, type: \1-\3
    (NOTE: This adds a standard dash; if you want an en dash, replace the standard dash with an en dash, which you can get by pressing Ctrl+[minus] on the number pad of a standard keyboard.)
  6. Click Find Next, then Replace if the instance found meets your criteria. Repeat.

How this works:

  • ([0-9]) represents any single numerical digit from 0 to 9
  • ( to ) looks for ‘to’ surrounded by a single space either side
  • \1-\3 replaces the first instance of ([0-9]) with itself (i.e. no change), then adds a dash, then replaces the second instance of ([0-9]) with itself (i.e. no change).

Update: Adrienne Montgomerie decided to test ChatGPT on creating a wildcard search for this. Here are her results:


Word: Shift punctuation to after a closing parenthesis

March 6, 2023

An editor on one of my editing Facebook groups put out a call for help. They wanted to find instances where punctuation preceded an opening parenthesis (typically used for a citation) and if possible, move that punctuation to after the closing parenthesis. For example: ‘Life is good. (Jones 2022) Here is the next sentence.’ should be ‘Life is good (Jones 2022). Here is the next sentence.’

In their example, the only punctuation is a period, but it could be a comma, semicolon or a full colon. (I’ll ignore exclamation points and question marks as they don’t play well with Word’s wildcard find as they are special characters used in wildcards.)

As with any find/replace, you need to identify the pattern you’re looking for—in this case, a punctuation character followed by a single space then an opening parenthesis, then varying text and numerals, followed by a closing parenthesis.

This is an ideal situation for wildcards! However, any such changes done globally could have unintended consequences, so my recommendation is to NOT click Replace All—instead, click Find Next followed by Replace once you’ve determined nothing will go wrong. The biggest thing that could go wrong is that there could be a citation that didn’t have a closing parenthesis immediately after it, in which case this find/replace would find the next closing parenthesis, which may not be part of a citation at all. Bottom line: DON’T click Replace All.

  1. Press Ctrl+h to open the Find/Replace window.
  2. Click More.
  3. Click the Use wildcards checkbox.
  4. In the Find What field, type (or, preferably, copy then paste) this:  ([.,;:])( )([\(])(*)([\)])
  5. In the Replace With field, type (or copy/paste) this: \2\3\4\5\1
  6. Click Find Next. If a correct string is found, click Replace (otherwise, click Find Next to see if the next one is a match you want to change). Repeat.

How this works:

  • There are 5 elements to the Find, with each enclosed in parentheses. Each element is represented internally within Word by a number, so the first element is treated as 1, the second as 2 etc. This becomes important for the Replace because you’ll use those numbers to represent what’s in the Find, and will reorder them to place the punctuation after the closing parenthesis.
    • The 1st element in the Find is ([.,;:]) — The outside parens tell Word to treat this element as one thing, the square brackets tell Word that the items within those brackets are the range of characters to find—in this case any comma, period, semicolon or colon.
    • The 2nd element in the Find is ( ) — The outside parens tell Word to treat this element as one thing, and inside the parens is a single space. So, look for the first element (any one of those punctuation characters), followed immediately by a space.
    • The 3rd element in the Find is ([\(]) — The outside parens tell Word to treat this element as one thing, the square brackets tell Word to find the character within those brackets—in this case an opening parenthesis. NOTE: Because parentheses are special characters in wildcard find/replace, you MUST ‘escape’ the character (using a \ )to tell Word to treat the opening parenthesis as a parenthesis and not as a special command. Our search string is growing and now means look for the first element (any one of those punctuation characters), followed immediately by a space, followed immediately by an opening parenthesis.
    • The 4th element in the Find is (*) — This is the command that is the potentially dangerous one and the reason why I advise you to NOT use Replace All with this find/replace—an asterisk inside parens like this tells Word to find ANYTHING. Any character, any numeral, any punctuation, any space, any tab… anything! And any number of them. Our search string now tells Word to look for the first element (any one of those punctuation characters), followed immediately by a space, followed immediately by an opening parenthesis, followed by ANYTHING until it gets to the 5th and final element (below), which is the closing parens.
    • The 5th and final element in the Find is ([\)]) — Explanation as for the 3rd element, but this time you need to ‘escape’ the closing parenthesis.
  • The Replace string is simple: When Word finds the matching pattern for the search, rearrange the elements above in this order: 2, 3, 4, 5 then 1 (the \ separates these numbered elements; note there’s no spaces between this string of numbers—if you add a space, then that would get added in the result in that place too). In other words, keep elements 2, 3, 4, and 5 in the same order, but move element 1 and put it after element 5. Because element 1 is the punctuation and element 5 is the closing parenthesis, the punctuation will now come after the parenthesis and be removed from before it.

Word: An excellent introduction to wildcard find and replace in Word

February 16, 2023

On the PerfectIt blog, they’ve written an excellent and clear introduction to Word’s wildcard find and replace syntax:

On this blog, I try to include the ‘why’ and ‘how this works’ with each of my posts that solve problems using Word’s find and replace wildcards. You can find all those posts here:

[Links last checked February 2023]



Word: Find and replace excess spaces and tabs before a paragraph mark

February 11, 2023

Over on one of the Facebook groups for editors, someone asked how to get rid of an assortment of tabs and spaces the author put in before pressing Enter.

This can be fixed quickly using Word’s wildcard find and replace. Here’s how:

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click More.
  3. Select the Use Wildcards checkbox.
  4. In the Find What field, type: ([ ^t]{1,})(^013) [NOTE: There’s a space immediately after the opening square bracket and before ^t]
  5. In the Replace field, type: \2
  6. Click Find Next.
  7. Assuming a string of spaces or tabs is found, click Replace, then Find Next. Repeat. Only click Replace All if you are confident you won’t replace a string of spaces or tabs that ARE necessary.

How this works:

  • There are two elements in the Find, both of which are enclosed in their own set of parentheses. Think of these as element 1 and element 2.
  • In the first element, [ ] encloses the things you want to find—it’s not a range, but single things, so there’s no dash separating the space and the ^t (^t is the code for a tab marker). This means Word will search for any space and/or tab.
  • After the [ ] and before the closing parenthesis of the first element is {1,}. This tells Word to look for one or more instance of the things inside the square brackets. So, one or more spaces, and/or one or more tabs. If you wanted to restrict it you could use, say, {2,5} which would look for 2, 3, 4, or 5 spaces or tabs only. If you had one tab or six or more tabs/spaces, these would not be found.
  • In the second element is Word’s wildcard code for a paragraph mark. In a standard find and replace, you’d use ^p, but when you use wildcards, this doesn’t work and you need to use ^013 instead.
  • In the Replace field, the \2 says to replace whatever space, tabs and paragraph marks are found with just a single paragraph mark. That is, replace element 2 with itself. Because there’s nothing for element 1, anything found in element 1 will be deleted.

Word: Find lower case letter after an opening quote mark and change to upper case

January 25, 2023

In one of the Facebook editors’ groups, someone asked: ‘[The author] presents dialogue like this — no capitalisation of the first letter, “a lovely day for it, isn’t it my dear.” Is there a way to change all the first letters of dialogue to upper case or is it just a matter of handling each one as it comes?/

You can use a wildcard find and replace to achieve this, but there are a couple of things you need to be aware of before deciding if this is what you want to do:

  • Unless you’re using ‘straight’ quote marks, you’ll have to copy/paste the opening quote mark used at the beginning of phrases like this. Why? Because curly/smart quote marks use a different character and won’t be found if you just type in a quote mark
  • Don’t use Replace All as you might replace things you don’t want to replace (e.g. if you’ve use ‘air’ quotes around a term [see what I did there?])
  • When you change the case to All caps, that setting will remain in the document for all the quote marks and lower case letters you changed. If you type immediately after that first letter, that text will likely be in upper case too (just like bold and italic if you don’t turn them off). If you later remove formatting from those quote/letter combos, you’ll get the lower case letters again. One way to avoid this would be to use the Find command to find each instance you need to change, then don’t replace—change them manually (Shift+F3 toggles between upper, lower, title and sentence case and is a quick way to change case)

Here’s how (Word for Windows):

  1. Press Ctrl+h to open the Find/Replace window.
  2. Click More, then select Use wildcards.
  3. Put this in the Find field (NOTE: paste your OWN opening quote mark in between the first set of parentheses): (“)([a-z])
  4. In the Replace field, type: \1\2
  5. With your cursor still in the Replace field, click the Format button, then Font, then select the All Caps checkbox, then OK. Below the Replace field you should see ‘Not Small caps, All caps’, as shown in the screenshot.
  6. Click Find. Check that Word has found what you want, then click Replace. Repeat. Only click Replace All if you are absolutely sure you won’t change anything else.
  7. If it finds nothing, then you likely have the wrong character for the quote marks inside the first set of parentheses in the Find field—copy the correct character from the text and put that inside the first parentheses.

Find/replace window showing commands find and replace commans and text below Replace field indicating that All Caps has been selected as part of the replace

How this works:

  • (“)([a-z]) — separates the opening quote mark and the immediately following lower case letter, represented by the range [a-z] (note the lower case in this range—you are only looking for a lower case letter immediately following a quote mark). Both parts of the
  • \1\2 — replaces what’s in the first (\1) and second (\2) set of parentheses with itself (i.e. no change to the text characters found)
  • Not small caps, All caps — the information about how the case will change according to the font setting you chose

Word: Find italic punctuation and replace with normal

January 10, 2023

An editor on Facebook asked: How do I search for incorrectly italicized punctuation, when the surrounding text is roman and the punctuation has gotten accidentally swallowed into the italics?

You need to use a wildcard find and replace for this, but be aware that if you have several sentences in italics, then it will find the punctuation within those too, so you might want to find them one at a time and do Replace, not Replace All.

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click More, then select the Use wildcards checkbox.
  3. With your cursor in the Find field, click Format > Font, then select Italic.
  4. In the Find field type: ([,.:\?\!])
  5. Put your cursor in the Replace field, then click Format > Font > Regular.
  6. In the Replace field type: \1
  7. Click Find Next, then Replace for each one you find that shouldn’t in italics. Repeat until done.

You can use the same search for bolded punctuation—just change the selection at step 3 to Bold.

Note the \ in front of the ? and !. Both characters are part of the special characters in wildcard searches, so they need to be ‘escaped’ and treated like normal characters, which is what the \ does.


Word: Change font colour for certain elements using find and replace

November 27, 2022

Cathy emailed me for help. She said:

I have a list of instructions, and each set of instructions is preceded by the word “Step” and a number. I want to change the font of both the word “Step” and the number without changing the number itself. I have tried using the Find & Replace function but have been unsuccessful after multiple attempts. Obviously, I’m not getting the proper syntax, so how can I accomplish this task using that function or is there another/better way other than converting all the information manually?

This can be done easily with a wildcard Find and Replace.

  1. In Word for Windows, press Ctrl+h to open the Find and Replace window at the Replace tab.
  2. Click More.
  3. Select the Use Wildcards checkbox.
  4. In the Find What field, type: (Step [0-9]{1,})
  5. In the Replace With field, type: \1
  6. With your cursor still in the Replace field, click Format, then select Font. Chose the font colour, then click OK. The font colour will be listed below the Replace With field.
  7. Click Find Next, then Replace. Only click Replace All if you are confident that you’ll only change the font of the items you want to change.


  • The \1 in the Replace field tells Word to replace whatever it found within the parentheses with itself (i.e. make no changes to the text, except the styling changes such as font colour).
  • The [0-9] tells Word to find any numeral.
  • The {1,} after the [0-9] tells Word to find any numeral that’s one digit or more (e.g. 1, 15, 235, 5467, 21678 etc.). If you wanted to find two or more numerals together (e.g. 25, 235, but not 5), you’d use {2,}, and if you wanted one to three digit numbers (i.e. 1 to 999, and NOT 1234, 123454 etc.), then you’d use {1,3} where 1 is the least number of characters to be found and 3 is the most.

Word: Get rid of all sorts of manually applied character formatting

November 23, 2022


In an editors’ Facebook group, E asked:

In Word, is there a way to highlight every bit of text that has had additional formatting applied (i.e. formatting that’s not part of the Word style for that text)?

For example, let’s say someone working on the file has applied a custom colour to every third paragraph. The custom colour is a shade of grey that is imperceptibly lighter than the standard black text that’s part of all the styles in the document, so I may not notice it just by looking at the document. But when I click within one of those paragraphs, the style name in the Styles pane is ‘Normal + Custom Colour xyz’. This same person has also randomly applied a clear background pattern to some bits of text, and so clicking on those bits of text shows a style name of ‘Normal + Pattern: Clear.

Is there a way to easily find/highlight all bits of text that have any style variations at all (i.e. ‘+ [anything at all]’ in the style name)?


There are at least 4 possible solutions to this problem—there may be more, but these were the 4 that came to mind in a couple of minutes. The solutions go from easiest to more complex. All are for Word for Windows.

WARNING: You’ll be making global changes to your document, so PLEASE PLEASE PLEASE test these techniques on a COPY of your document before making them on the original.

Method 1: Delete the created character styles from the Styles pane

First, you need to show the Styles pane and then all the formatting in the Styles pane. From the Styles pane, you can click the drop-down arrow for a character formatting (or ‘pattern’ style and select Delete, which clears the character formatting from all the text that uses it.

  1. Open the Styles pane (Alt+Ctrl+Shift+S).
  2. Click Options (at the very bottom of the Styles pane).
  3. Select the top 3 checkboxes for showing formatting.
    Style  Pane Options with first three checkboxes selected and with Alphabetical as the sort order
  4. While you’re there, sort the list alphabetically for ease of identifying the style names, then click OK.
  5. in the Styles pane, identify the added character styles—look for names like ’10pt, italic’. For background shading, look for style names like ‘Pattern: Clear (Text 2)’.
  6. To clear these character or pattern attributes from the text, click the drop-down arrow to the right of the style name in the Styles pane, then select Delete.
    Click the drop-down arrow to the right of the style name, then click Delete to remove it
  7. Click Yes to delete all instances.

Bam! They’re gone!

Finally, if seeing all those character formatting names in the Styles pane annoys you in the future, go back to steps 2 and 3 above and clear those checkboxes

Method 2: Reset the formatting of each paragraph/whole document back to the underlying paragraph styles

You can reset each paragraph (or the entire doc if you’re brave!) to its underlying paragraph style (e.g. if it’s Body Text + 10pt italic, this technique will reset it to just Body Text and remove the character formatting). NOTE: This technique does not remove any coloured backgrounds.

The easiest way to reset to the underlying style is by selecting the text (one or more paragraphs, or Ctrl+A to select the entire document), then pressing Ctrl+spacebar. This gets rid of the manually applied character styles but not the coloured shading. You may have to do it twice if it doesn’t get them all first time round.

Method 3: Reset the background shading to ‘no colour’

If you used Method 2 above, then you’ll still need to get rid of the shading. The easiest way is to:

  1. Select the entire document (Ctrl+A).
  2. Go to the Home tab > Paragraph group and click the drop-down arrow immediately to the right of the borders and shading icon.
  3. Select Borders and Shading.
    Home tab > Paragraph group > click drop=down arrow next to the Borders and Shading icon, then select Borders and Shading at the bottom of the drop-down list
  4. Select the Shading tab.
  5. Change the Fill to No Color (this may already be displayed, but you’ll still need to click the drop-down arrow and select it from below the color palette to set it).
  6. Click OK.

Select the Shading tab, click the drop-down arrow for the Fill colour, select No Color, then click OK.

Method 4: Use a wildcard find and replace to reset the character formatting (this does not change the shading, however)

Note: Test this technique on a COPY of the document as it makes a global Replace All change.

  1. Press Ctrl+H to open the Find and Replace window.
  2. Click More.
  3. Select the Use Wildcards checkbox.
  4. In the Find What field, type * (* = every character).
  5. Put your cursor in the Replace With field, then click the Format button at the bottom of the window. DO NOT TYPE ANYTHING INTO THE FIND WHAT FIELD!
    On the Replace tab, click More see the option to Use Wildcards and select that checkbox, then type * into the Find What field. Put your cursor into the Replace With field and click Format and select Font. Choose your font settings and click OK. Underneath the Replace With field should be the settings you chose, and NOTHING should be in the Replace With box. Click Replace All.
  6. Select Font to open the font dialog box.
  7. Set the font colour to Automatic, font style to Regular, and the font size to what you want all the found text to be. Click OK.
  8. Below the Replace With field you should have information about the font, such as ‘font size, not bold, not italic, font colour = Auto’.
  9. Click Replace All (Note: You have to click Replace All as Replace will find EVERY. SINGLE. CHARACTER in your document, one at a time…).

Word: Find all upper case words within parentheses and change to lower case

March 6, 2022

One of my readers asked if there was a way to change upper case strings within parentheses to lower case. For example, (INHALED DEEPLY) to (inhaled deeply). It seems they had hundreds of them, so doing them one at a time wasn’t the most efficient use of their time.

I was able to come up with a wildcard find to identify them all, but I couldn’t come up with a replace that preserved the contents while changing the case. I fiddled around a bit trying to get a macro to work, but to no avail. Then I decided to ask my question on the Microsoft support forums, but before I did so, I did a quick search to see if an answer had already been given—and it had! (

NOTE: As always, test on a copy of your document before you run this—you are making a global change that may target more than you want. For example, these will all get changed to lower case:

  • upper case acronyms in parentheses
  • anything inside parentheses that starts with a capital letter, such as proper nouns, whether in all upper case or not
  • everything from the first upper case letter after an opening parenthesis to the first-found closing parenthesis, which might be some pages later if you forgot to close the parenthesis.

This is a brute force method and may have unintended consequences. If in doubt, click Find Next to check each instance before you make this global change. 

Steps to achieve this:

  1. Press Ctrl+h to open the Find and Replace window.
  2. Click the Find tab (this is important).
  3. In the Find What field, type \(([A-Z]*)\)
  4. Click More and select the Use wildcards checkbox.
  5. Click Find In and select Main Document from the drop-down list.
  6. All matches are found and automatically selected. DO NOT click inside the document otherwise you will lose the selections.
  7. Go to the Home tab and click the Aa icon in the Font group and change the case to lower case. This will change the case of everything selected.

[Link last checked March 2022]