Wildcard Find and Replace in Word 2004

F

Fogharty

I am working on some tests and evaluations where the author did not
use numerals and tabs correctly.

I want to be able to use a wildcard search to find, for example "1.
^t^t" and replace it with "^t1.^t" and the "1" would whatever number
from 0-9. In other words, I want to search once, then do a replace
that will fix the formatting of the tabs and keep the numbers the
same.

Can this be done?
 
J

John McGhie

Yes, it can be done.

Now, let's see if I can remember how... :)

Ah hah! I knew I had this somewhere...

Find What is:

([0-9].)(^t^t)

Replace with is:

^t\1^t

And "Use Wildcards" must be turned on.

What this does is divide the find into two regular expressions, using ( and
).

The first expression finds any SINGLE digit 0 to 9 followed by a period.
The second expression finds the two consecutive tabs.

Then in the Replace, we add a tab, whatever the first Find expression found,
and another tab. We discard the result of the second find expression (the
two tabs).

If your number series exceeds one digit, you need to double the [0-9] in the
first expression and run that first to do all the two-digit numbers, then
remove that and run again to do the single digit numbers. If you try to do
the singles first and then the doubles, you'll break it :)

Hope this helps


I am working on some tests and evaluations where the author did not
use numerals and tabs correctly.

I want to be able to use a wildcard search to find, for example "1.
^t^t" and replace it with "^t1.^t" and the "1" would whatever number
from 0-9. In other words, I want to search once, then do a replace
that will fix the formatting of the tabs and keep the numbers the
same.

Can this be done?

--

Mactopia is currently broken: the helpers are not seeing any of the
questions being posted. Microsoft is working on the problem. In the
meantime:

To successfully post in here, either use Google:
http://groups.google.com/group/microsoft.public.mac.office.word?lnk=

Or Microsoft Communities:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=micros
oft.public.mac.office.word&cat=en_US_3cf8ecf1-ca81-4391-b07d-8933029ee8a9&la
ng=en&cr=US

Or in Entourage, use the pre-configured Microsoft News server:
See "setting up Entourage for Newsreading" here:
http://word.mvps.org/Mac/AccessNewsgroups.html

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
F

Fogharty

What would I do without you John!

A couple of things I've discovered:

I can't just copy and paste the search terms from my browser to my
Find dialog in Word... it only works if I type it in by hand.

I had to tweak the Replace
^t\1^t
With
^t\1.^t
to keep the decimal point there.

But otherwise... goodness! This will save me a load of time.

Now if I can get my other problem fixed, I'll be good to go!

Thanks!
 
J

John McGhie

The Replace should not have needed tweaking :)

The "\1" replaces "Whatever was found". So check your "Find What" to ensure
that you have included the decimal point inside the parentheses, so that it
becomes one of the "found" characters.

Otherwise, this thing will fire on "any digit" and you don't want that :)

Cheers


What would I do without you John!

A couple of things I've discovered:

I can't just copy and paste the search terms from my browser to my
Find dialog in Word... it only works if I type it in by hand.

I had to tweak the Replace
^t\1^t
With
^t\1.^t
to keep the decimal point there.

But otherwise... goodness! This will save me a load of time.

Now if I can get my other problem fixed, I'll be good to go!

Thanks!

Yes, it can be done.

Now, let's see if I can remember how... :)

Ah hah!  I knew I had this somewhere...

Find What is:

([0-9].)(^t^t)

Replace with is:

^t\1^t

And "Use Wildcards" must be turned on.

What this does is divide the find into two regular expressions, using ( and
).

The first expression finds any SINGLE digit 0 to 9 followed by a period.
The second expression finds the two consecutive tabs.

Then in the Replace, we add a tab, whatever the first Find expression found,
and another tab.  We discard the result of the second find expression (the
two tabs).

If your number series exceeds one digit, you need to double the [0-9] in the
first expression and run that first to do all the two-digit numbers, then
remove that and run again to do the single digit numbers.  If you try to do
the singles first and then the doubles, you'll break it :)

Hope this helps

--

Mactopia is currently broken: the helpers are not seeing any of the
questions being posted. Microsoft is working on the problem. In the
meantime:

To successfully post in here, either use Google:
http://groups.google.com/group/microsoft.public.mac.office.word?lnk=

Or Microsoft Communities:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=micros
oft.public.mac.office.word&cat=en_US_3cf8ecf1-ca81-4391-b07d-8933029ee8a9&la
ng=en&cr=US

Or in Entourage, use the pre-configured Microsoft News server:
See "setting up Entourage for Newsreading" here:
http://word.mvps.org/Mac/AccessNewsgroups.html

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 
D

dow

The Replace should not have needed tweaking :)

The "\1" replaces "Whatever was found".  So check your "Find What" to ensure
that you have included the decimal point inside the parentheses, so that it
becomes one of the "found" characters.

Otherwise, this thing will fire on "any digit" and you don't want that :)

Cheers

What would I do without you John!
A couple of things I've discovered:
I can't just copy and paste the search terms from my browser to my
Find dialog in Word... it only works if I type it in by hand.
I had to tweak the Replace
 ^t\1^t
With
^t\1.^t
to keep the decimal point there.
But otherwise... goodness! This will save me  a load of time.
Now if I can get my other problem fixed, I'll be good to go!

Yes, it can be done.
Now, let's see if I can remember how... :)
Ah hah!  I knew I had this somewhere...
Find What is:
([0-9].)(^t^t)
Replace with is:
^t\1^t
And "Use Wildcards" must be turned on.
What this does is divide the find into two regular expressions, using ( and
).
The first expression finds any SINGLE digit 0 to 9 followed by a period.
The second expression finds the two consecutive tabs.
Then in the Replace, we add a tab, whatever the first Find expression found,
and another tab.  We discard the result of the second find expression (the
two tabs).
If your number series exceeds one digit, you need to double the [0-9] in the
first expression and run that first to do all the two-digit numbers, then
remove that and run again to do the single digit numbers.  If you try to do
the singles first and then the doubles, you'll break it :)
Hope this helps

 --

Mactopia is currently broken: the helpers are not seeing any of the
questions being posted.  Microsoft is working on the problem.  In the
meantime:

To successfully post in here, either use Google:http://groups.google.com/group/microsoft.public.mac.office.word?lnk=

Or Microsoft Communities:http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg...
oft.public.mac.office.word&cat=en_US_3cf8ecf1-ca81-4391-b07d-8933029ee8a9&la
ng=en&cr=US

Or in Entourage, use the pre-configured Microsoft News server:
See "setting up Entourage for Newsreading" here:http://word.mvps.org/Mac/AccessNewsgroups.html

This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]

Pasting into the Find-and-replace dialog:

I often have problems with this. I not infrequently get blocks of text
from web-pages etc, which comes in with inappropriate line-endings of
some sort which need removing.

If I paste that text into Word 5, I can select whatever is at the end
of the line, and paste it into the Replace box. Word 2008 won't let me
paste anything in. I sometimes can't tell what the particular line-
ending character actually IS, so I don't know what to actually type
into the dialog...

Any suggestions? (other than sticking to Word 5, which is what I would
like to do!)
 
J

John McGhie

Hi Dow:

I cannot understand what you mean?

Pasting into Word 2008's Find box works fine for me. Wild cards are ASCII
symbols, so you can paste them readily. You can't paste line-enders because
they are significant characters in the search: you have to use either ^l, ^m
or ^p, depending on which one you want.

Cheers


Pasting into the Find-and-replace dialog:

I often have problems with this. I not infrequently get blocks of text
from web-pages etc, which comes in with inappropriate line-endings of
some sort which need removing.

If I paste that text into Word 5, I can select whatever is at the end
of the line, and paste it into the Replace box. Word 2008 won't let me
paste anything in. I sometimes can't tell what the particular line-
ending character actually IS, so I don't know what to actually type
into the dialog...

Any suggestions? (other than sticking to Word 5, which is what I would
like to do!)

--

The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:[email protected]
 

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