Format Lines in an .rtf document after specified tags

Posted on 2014-09-22
Last Modified: 2014-09-22
Someone sent me a .txt file with information that they ultimately want to be placed in a FileMaker database, but I have to do some work on it before it gets there. I copied the text in to a Word file and saved it as an .rtf file. What I am needing to do is have the lines after the tags be changed to a bold format and the tags removed. Below is a sample of the data given to me (with names and addresses changed for privacy). There are over 74,000 words in the document so I need some way to automate the task.
@T=Echo Hill,  Ryanville, Any State
@I=Location: 6 miles north of Ryanville on Hwy Z72 at the Hwy A71 intersection
John Henry, Box 1234, Ryanville, ZZ 12345
@S=Echo Hill School
Box 9999, Andyville, ZZ
@S=Board Members
Harvey Junior
Gavin Sarupta
Sergio Gonzalves

Here is how I would like it to look.
Echo Hill,  Ryanville, Any State
Location: 6 miles north of Ryanville on Hwy Z72 at the Hwy A71 intersection
John Henry, Box 1234, Ryanville, ZZ 12345
Echo Hill School
Box 9999, Andyville, ZZ
Board Members
Harvey Junior
Gavin Sarupta
Sergio Gonzalves

How would I go about changing the selected lines to a Bold format?
Question by:wcsjas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 76

Accepted Solution

GrahamSkan earned 500 total points
ID: 40337370
Assuming that the lines are in fact paragraphs, you should be able to do that in Word using a wildcard Find and Replace. You can check this with the Show/Hide (¶) toggle button. This allows the format characters to be seen. The lines should end with the same pilcrow symbol, so:

@T=Echo Hill,  Ryanville, Any State¶

Select all of the text that needs to be changed. Unless there are tagged lines that you wish to exclude, use Ctrl+A to select the whole document.

Open the Find and Replace dialogue with Ctrl+H.

Type this in the Find box:

Open the hidden part of the dialogue with the More>> button, and tick the 'Use Wildcards' checkbox.

Type this into the  Replace box:

Set Bold format via the Format button, Font... item.

Click on the Replace All button.

Author Comment

ID: 40337466
That definitely did the trick! Can you explain (or point me to a website) how that works? That's some fancy 'Find and Replace' that I've never seen. I think I can follow this part \@[A-Z] but the rest of it didn't quite make sense.

Author Closing Comment

ID: 40337468
Thanks for the quick reply!
Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

LVL 76

Expert Comment

ID: 40337595

\     is the escape character in this context, so \@ means 'look for the @ character, and do not use its special meaning in Word search'
[A-Z]     means any upper-case letter
{1}     means one only of the previous list in the square brackets
=      as is
(       start of the first replacement string
*      any number of any character until the next searched-for character
^13    paragraph mark. Note that in the replace string and in all non-wildcard find or replace strings, ^p will do the same job.
)      end of the first replacement string

For the replacement code, \1 means, replace with the string found within the first round-bracketed text in the Find

Here is an excellent reference link;
LVL 32

Expert Comment

by:Paul Sauvé
ID: 40337623
Graham - you knowledge of (what I consider) obscure uses of Word functions always impresses me!


Author Comment

ID: 40337689
Wow! Thanks again. Learn a little every day!
LVL 76

Expert Comment

ID: 40337807
Thanks Paul,
I'm still crap with pictures :)

It is a pleasure to help anyone who wants to learn

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

726 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