Solved

word 2010 find and replace wildcards and formatting

Posted on 2013-02-01
13
907 Views
Last Modified: 2013-03-01
I have a large number of Word documents that have been poorly formatted. Many of them are just glossaries of terms where the paragraph starts with the word or phrase and a colon, then a space and the definition. Each entry is separated by 2 paragraph markers since the author didn't know about space after or space before options.

I want to search for the text between the 2 paragraphs and the ": space" and replace it with a character style to make it stand out (such as bold, but I'd probably use a style entry, not just font bold).

Can someone suggest how to search for a string of text between specific characters like the ^p^p pair and the ": " pair? I may just go into the documents and replace all the ": " with something like a tab or ~ and then convert text to table columns, but that might put my document in a layout I don't want to keep.
0
Comment
Question by:Shannon Mollenhauer
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 7

Expert Comment

by:Beneford
Comment Utility
On the find replace dialog, open the More section and use 'special' button to select the paragraph mark (^v).
You can also add formatting to the replace text if you want to.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
Are the ': ' and the '^p^p' always in one string?

If so,
Find what: : ^p^p
Replace with: :^p

What you can do is select a unique paragraph style for the Replace with: ^p.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
If this is NOT the case, please post PART of a file with what you want to reformat and simply change the text, but not the format of one existing file.
0
 

Author Comment

by:Shannon Mollenhauer
Comment Utility
The sample looks like this:

^p
^p
Term to be defined: Definition text defining the term.^p
^p
Another term:

What I am after is to find the text "^p^pWhatever term is before the colon and the colon itself" and replace it with bold formatting or replace it with a style sheet element that includes bold or whatever I choose. It should end up like this:
^p
^p
Term to be defined: Definition text defining the term.^p
^p
Another term: Another definition of that term.^p
^p

I'm familiar with how to specify the formatting I want in the replace field. What I can't get to work is any combination of special marks codes like ^p and wildcards for the text between the previous ^p and the colon/space combination.
0
 

Author Comment

by:Shannon Mollenhauer
Comment Utility
I know there are ways to apply formatting to elements of text in a string in Adobe InDesign which helps for formatting paragraphs, catalog entries, etc. (see Adobe's Classroom in a book for the exercise). I was just hoping I could accomplish something similar in Word because I've probably got about 80 pages of these kinds of glossary documents. It might just be easier to replace the ": " with a special symbol, convert text to table, and format the first column with the style I want, then hide grid lines and borders so it doesn't look so "tabular". Then I can add new columns for additional information about each entry and do exports to other platforms easily.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
It looks like you may have to resort to a VB macro command to accomplish this - not really my area of expertise...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
I have to go right now, but I'll have a second look when I get back in a few hours.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
I have found an obscure solution to your problem. I know it is possible to have a paragraph mark that doesn't change lines by adding a control code. But I can't remember what the code is. Basically, you have two paragraphs on a single line. I saw this in one of my documents some years ago, so I know that it exists.
0
 

Author Comment

by:Shannon Mollenhauer
Comment Utility
PaulSauve:
I'm not worried about the two paragraph marks. I'll replace those with a single paragraph and space after style later. I'm just trying to find a way to select the words at the beginning of the next paragraph up to the : and apply formatting to it.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
What I am saying is that it is possible to have TWO paragraphs in a single line - I just can't remember how to do this
0
 
LVL 21

Accepted Solution

by:
EricFletcher earned 350 total points
Comment Utility
Coincidentally, I've just had to do exactly this for a job I'm currently working on.

First, use Find and Replace to flag the start of the strings ending with the colon so you can later use the wildcard F&R to set the font attribute: in Find what, use ^p^p and in Replace with, use ^pþ (I used Alt-0254 here for the þ but any unique character or string is okay).

Now use F&R with wildcards to set the font attribute for the characters up to and including the colon:
turn on the Use wildcards checkbox (click More>> to reveal it)
in Find what, use (þ)(*:) [note the parentheses]
in Replace with, type \2
press Ctrl-B to set the Format to Font: Bold
click Replace All

This finds patterns consisting of þ and any number of characters up to and including a colon. The parentheses set it up as two expressions so the replace operation can deal with them differently. Here, \2 causes it to replace the found pattern with just the 2nd expression, and effectively removes the þ character used as the flag. The replace also applies the font attribute to the content found in the 2nd expression.

Note that you can specify the format via the Format button in F&R; here I just used the Ctrl-B shortcut to apply bold. In my application, I applied a character style (Format > Style...) because I wanted to both alter the font and be able to use it in a STYLEREF field code for page headers.
0
 
LVL 21

Expert Comment

by:EricFletcher
Comment Utility
I posted before adding a note re PaulSauve's comment above. To break a paragraph without starting a new line, press Ctrl-Alt-Return to insert a "style separator" character. It shows up as a hidden pilcrow (¶), and allows you then to apply a different style on each side of it.

This can be used to get run-in heads included in tables of contents: the 1st part might be tagged with, say, Heading 5, and the second with, say, Body Text so the TOC field would pick up the run-in Heading 5 part.
0
 
LVL 31

Expert Comment

by:Paul Sauvé
Comment Utility
Eric - EUREKA, that's exactly what I couldn't remember... Thanks a lot.

Paul :-)
0

Featured Post

A Knowledge Base That Stays Up-to-Date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now