wildcard replace?

E

ekeby

God am I glad I found this forum--I hope someone can help. I've
searched past posts and not sure this has been answered--maybe I don't
understand the subject well enough.

I'm prepping a Word document to import into Quark. The document is a
directory, and the client wants changes to the formating. For example,
all of the phone numbers are written

608.555.1212

that is, with periods between area code and exchange and number. The
client wants them to read

Tel: (608) 555-1212

Each item to be changed is on a line by itself. Is it possible to make
this kind of a change with a global find and replace in Word?

Thanks!
Nicol K
EKEBY
 
M

Michel Bintener

Hi Nicol,

yes, that can be done, and here's how. First of all, make sure that you've
got the wildcard search enabled. Then, in the Find field, enter the
following line:

([0-9]{3}).([0-9]{3}).([0-9]{4})

Translated, this means "find a string of three numbers, then a dot, then
another string of three numbers, then another dot, and then finally a string
of four numbers." Now, enter this line into the Replace field:

Tel: (\1) \2-\3

This means "add Tel: , then put brackets around the first string, then a
space, then the second string and a hyphen followed by the first string." It
should work, I've just tested this.
 
M

Michel Bintener

This means "add Tel: , then put brackets around the first string, then a
space, then the second string and a hyphen followed by the first string."

Sorry, that should read "a hyphen followed by the *third* string."
 
E

ekeby

many many thanks--

next question: does that work with text as well? Replacing 0-9 with
a-z? This same directory has email addresses that the client wants to
precede with
E-mail:
The only constant I see is that they all have an @ symbol.

I believe the other changes I know how to do, and that I can adapt
your command line to change hyphens between years to en dashes:

([0-9]{4})-([0-9]{4})

and then repeat with en dash replacing hyphen--would that be correct?
 
E

ekeby

Actually, I realize that the email address always follows the fax
number, so that once I made the necessary change to the fax number, I
could search for that along with the return that follows it, repeat it
all but add the word E-mail: after the return. However, I don't know
that every single entry has a fax number.

Another situation in this file: sometimes dates are included without
word spaces, as in September4,1946. I think I could first search and
replace
([0-9]{2}),([0-9]{4})
and then repeat it to cover 1-digit dates . . . .??
 
M

Michel Bintener

Hello again,

I had to some experimenting before I got this right, I normally don't use
wildcard search in Word and it's not *that* easy, to be honest.

To insert the "E-mail: " tag, do the following Find and Replace (again, with
wildcards enabled):

Find: ([A-z]{1,})\@
"a string with one or more letters, whether capitalised or not, followed by
the @-sign" ("\@", as "@" all by itself has a different meaning in wildcard
search)
Replace: E-mail: \1@
"E-mail: , plus the first string followed by an @-sign" (note that in the
Replace field, you can use the @ without the backslash)

This works with email addresses that look like yours, no punctuation between
names. If you happen to have some of these, this wildcard search won't work
as expected, so post back if that's the case, and I'll look into it.

For the dates:

Find: ([0-9]{1,}),([0-9]{4})
"a string with a sequence of at least one number, followed by a comma, then
another string of four numbers"
Replace: [SPACE]\1, \2
"space, first string, comma, space, second string" (note that you'll have to
replace the initial [SPACE] with a normal space, I just put it there to make
it obvious that you'll have to insert a space before the first string in
order to separate the days from the months)

I hope this was helpful. If you want to find out more about wildcards, you
might want to read this really helpful article on the Microsoft Word MVP
website: http://word.mvps.org/faqs/general/UsingWildcards.htm

This part of the website does not display properly in Safari, so you'd
better use a different browser to navigate to it; alternatively, hit refresh
a couple of times in Safari, and you *should* be able to see it.
 
E

ekeby

Hi Michael . . . I'm finally in production on this job . . . and I
find that the above is not working for me. I cannot achieve a "find"
with:

([0-9]{3}).([0-9]{3}).([0-9]{4})

I can only achieve a find with the first expression (or first plus
second without the following period), as in

([0-9]{3}). or ([0-9]{3}).([0-9]{3})

SO--I tried a replace using the first expression, using Tel: (\)

and what I got (for phone number 256.372.5478 was

25(6) 372.5478

that is, only the last digit of the area code got put in parentheses.
Am I doing something wrong?

Nicol K
 
M

Michel Bintener

Hi Nicol,

I don't understand why this is not working for you. As I said, I tried it
myself, and I definitely got the correct result by performing that wildcard
search. Since it seems to work for the first two expressions, are you
absolutely sure that the numbers are typed the way you described in your
first post, three numbers, dot, three numbers, dot, four numbers? Is there
no space between, or anything else that might disrupt the wildcard search?
What follows the string of four numbers, a line return, a punctuation mark?
Also, when you say that it's not working, what exactly does that mean? Do
you get an error message of some kind, or is Word not picking up any
expressions that match the search criteria?


Hi Michael . . . I'm finally in production on this job . . . and I
find that the above is not working for me. I cannot achieve a "find"
with:

([0-9]{3}).([0-9]{3}).([0-9]{4})

I can only achieve a find with the first expression (or first plus
second without the following period), as in

([0-9]{3}). or ([0-9]{3}).([0-9]{3})

SO--I tried a replace using the first expression, using Tel: (\)

and what I got (for phone number 256.372.5478 was

25(6) 372.5478

that is, only the last digit of the area code got put in parentheses.
Am I doing something wrong?

Nicol K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top