h1

Word: Find text between quote marks and change to italic

June 5, 2019

All special terms in a Word document I worked on were surrounded by straight double quote marks. I wanted to remove the quote marks and italicise the term. For example, I wanted “term” to become term.

This was a relatively easy task using wildcards in Word’s find and replace, but there are a couple of ‘gotchas’—it won’t catch anything in curly (smart) quotes or inside single quote marks (straight or curly), or if there’s US-style punctuation (e.g. period, comma) at the end, such as “term.” I’ve added alternatives to deal with these situations. It also won’t catch more than one word inside the quote marks, and I don’t have an easy solution for that.

In ALL cases below:

  • you must have Use wildcards checked in the advanced Find and Replace dialog box
  • for the italics, when you’re in the Replace field, select Format > Font> and choose Italic
  • all the double and single straight quotes here DO NOT display correctly, so DO NOT copy/paste from here—instead, type the quote marks in directly from your keyboard

Case 1: Double straight quotes

  • Find: (“)(<*>)(“)
  • Replace: \2

For those preferring to use ACSII codes, a double straight quote mark is ^034.

Case 2: Single straight quotes

  • Find: (‘)(<*>)(‘)
  • Replace: \2

For those preferring to use ACSII codes, a single straight quote mark is ^039.

Note: This may not work—if it doesn’t, try (‘)(*)(‘) as the Find, but be careful when replacing as a single quote mark is also used as an apostrophe. DO NOT do Replace All.

Case 3: Double curly quotes

  • Find: (“)(<*>)(”)
  • Replace: \2

For those preferring to use ACSII codes, an opening double curly quote mark is ^0147 and a closing one is ^0148.

NOTE: It’s easier to copy a curly quote from the main Word document and paste it into the Find. Don’t forget to copy an opening one for the left part of the Find string, and a closing quote for the right part.

Case 4: Single curly quotes

  • Find: (‘)(<*>)(’)
  • Replace: \2

For those preferring to use ACSII codes, an opening single straight quote mark is ^0145, and a closing single straight quote mark is ^0146.

Note: This may not work—if it doesn’t, try (‘)(*)(‘) as the Find, but be careful when replacing as a single quote mark is also used as an apostrophe. DO NOT do Replace All.

NOTE: It’s easier to copy a curly quote from the main Word document and paste it into the Find. Don’t forget to copy an opening one for the left part of the Find string, and a closing quote for the right part.

Case 5: Period or comma inside the closing quote mark

Use the relevant Find from any of the above, depending on the style of quote marks you’re looking for, and add an extra command ([,.]) to find the comma or period too. For straight double quotes, you’d change it to:

  • Find: (“)(<*>)([,.])(“)
  • Replace: \2\3

If you want to keep the punctuation, then you need to add \3 to the Replace. If you don’t want to keep the punctuation, then just leave it as \2. Again, don’t forget to set the Replace to italic font. The end result will be an italicised word with its trailling punctuation also in italics.

If don’t want the punctuation in italics, then you’ll need to run another find/replace using wildcards to change the punctuation back to normal text:

  • Find: ([,.]) (this time, set the Find to italics using Format > Font > Italic)
  • Replace: \1 (for this one, set the Replace to NOT use italics using Format > Font > Regular)

 

 

4 comments

  1. I tried the first four examples, with interesting results.

    Cases 1 and 3 worked perfectly. I even tried a modification, by dropping the parentheses around the quotation marks and replacing group 2 with group 1, and that worked too.

    Cases 2 and 4, however, did not work, with or without parentheses. I tried generating the straight character by typing in the ASCII (hex) character code, with no luck.

    I wonder why my results were inconsistent?


  2. Hi Leslie

    That’s strange. I just retested this (in the same version of Word I used for the original testing just over a week ago), and the single quotes (straight or curly) don’t work for me now either. I changed my AutoFormat setting from smart to straight quotes as well, in case that was messing it up. I also tried the ASCII codes (below) but they didn’t work either. Nor did copy/pasting from the text. The only thing I got to work successfully was typing a single straight quote or ^0145 all by itself—as soon as I added the rest of the expression, it wouldn’t work.

    The ASCII code I found for a single straight quote was 39 (or ^039 in the find) and for a single curly quote 145 and 146 (^0145 and ^0146) for the opening and closing quotes respectively. You would have to type (^0145)()(^0146) for curly quotes, and (^039)()(^039) for the straight quotes.

    I’ll keep investigating to see if I can figure out what’s happening here—it definitely worked when I wrote up the instructions, but isn’t working now for some unknown reason.

    –Rhonda


  3. Hi again Leslie

    If I do this find without the beginning/end of word characters, it seems to work – (‘)(*)(‘). However, you’ll need to be careful and check each match before replacing as a single quote mark is also used for an apostrophe.

    I’ll add a note to the post about this, for those who don’t read the comments.

    –Rhonda


  4. Ah-ha–thank you! I’ve had some trouble in the past with “” representing a single word. Wildcards are great when they work, but they can sometimes be baffling.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: