Solved

word 2010 find and replace wildcards and formatting

Posted on 2013-02-01
13
911 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
ID: 38844035
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é
ID: 38844263
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é
ID: 38844321
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
ID: 38844340
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
ID: 38844348
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é
ID: 38844505
It looks like you may have to resort to a VB macro command to accomplish this - not really my area of expertise...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 31

Expert Comment

by:Paul Sauvé
ID: 38844509
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é
ID: 38845475
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
ID: 38845495
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é
ID: 38845645
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
ID: 38848782
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
ID: 38848843
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é
ID: 38849614
Eric - EUREKA, that's exactly what I couldn't remember... Thanks a lot.

Paul :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

930 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

14 Experts available now in Live!

Get 1:1 Help Now