Find and Replace with Wildcards

  • Thread starter Luke Muehlhauser
  • Start date
L

Luke Muehlhauser

I've been trying to figure out how to use find and replace in Microsoft
Word XP with wild cards. I read through
http://word.mvps.org/FAQs/General/UsingWildcards.htm and still wasn't able
to figure it out.

Here's what I want to do:

I have a large text file. Here is an excerpt:
--------
<h2>1910-1919</h2>
<i>20 films seen: 4 feature-length, 16 short</i><ol>
<li>Birth of a Nation, The (1915)
<li>Broken Blossoms (1919)
<li>Immigrant, The (1917) [short]
<li>Easy Street (1917) [short]
<li>Rink, The (1916) [short]
<li>(none yet)
<li>(none yet)
<li>(none yet)
<li>(none yet)
<li>(none yet)</ol>
<b>Also Recommended: </b>Winsor McCay, the Famous Cartoonist of the N.Y.
Herald and His Moving Comics (1911) [short]; Cameraman's Revenge, The
(1912) [short]; Pool Sharks (1915) [short]; Tramp, The (1915) [short];
Champion, The (1915) [short]; Ask Father (1919) [short];
<b>Meh: </b>Last Days of Pompeii, The (1913); Intolerance (1916); For His
Son (1912) [short]; Aeroplane Flight and Wreck (Piloted by M. Cody) (1910)
[short]; Girl and Her Trust, The (1912) [short]; Bangville Police (1913)
[short]; By the Sea (1915) [short]; Butcher Boy, The (1917) [short];
Adventurer, The (1917) [short];
<b>Garbage: </b>
---------

What I want to do is fix it so that all instances of [movie title],
[leading article] are switched to [leading article] [movie title].

I turned wildcards on and did a find and replace using the following values
for starters:

Find (without quotes): "; *; The"
Replace (without quotes): "; The *"

But, apparently * only works as a wildcard in find, and not replace (I
ended up with "; The *").

Does anyone know how to use wild cards in find and replace correctly to
accomplish what I like? Then I will adapt whatever you can tell me for use
with other articles and positions of movie titles (for example, after <li>
and </b> instead of ;).

THANKS TO ANYONE WHO CAN HELP!!!!
 
G

Graham Mayor

I have rewritten the article for my own web site to try and make it
clearer - see http://www.gmayor.com/replace_using_wildcards.htm but there
appears no simple way to do this as there is no unique string that can be
easily be selected. * is rather a blunt weapon :(

You replace wildcards by using brackets and slashed numbers eg The following
will step through the text, but will find more than just the items you
require so you will have to select next until the required string is found
then replace it.

(; )(<*)[,] (The) \(

Replace with

\1\3 \2\4 (

I might have been able to tie it down even tighter had I had access to the
original document, but this should get you started.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greg Maxey

Luke,

It may be due to how your example came across, but I can't find anyway to
find and replace all instances.

Using your example, the best I could find was:

Find:

;([!;,]{1,}),( The)

This starts with a semicolon, finds everything but a semicolon and comma up
to a comma, finds the comma, a space and the word The. It groups everything
from the semicolon up to the comma as group 1 and The as group 2. Then we
simply replace the semicolon with itself and reverse the groups

Replace:

;\2\1

Which worked with:
The Cameraman's Revenge, The Tramp, The Adventurer, The Butcher Boy and The
Girl and Her Trust

It missed Birth of a Nation, The/Immigrant, The and Rink, The because there
is no ";" tag at the begining of these lines.

You can pick up these three with

li\>([!,]{1,}), (The)

and

li>\2 \1

That leaves Last Days of Pompei, The

As you can see, there is no common string in your structure to ensure each
instance is picked up. Maybe there is and I just don't see it.





--
Greg Maxey
A peer in "peer to peer" support
Rockledge, FL
To e-mail, edit out the "w...spam" in (e-mail address removed)

Luke said:
I've been trying to figure out how to use find and replace in
Microsoft Word XP with wild cards. I read through
http://word.mvps.org/FAQs/General/UsingWildcards.htm and still wasn't
able to figure it out.

Here's what I want to do:

I have a large text file. Here is an excerpt:
--------
<h2>1910-1919</h2>
<i>20 films seen: 4 feature-length, 16 short</i><ol>
<li>Birth of a Nation, The (1915)
<li>Broken Blossoms (1919)
<li>Immigrant, The (1917) [short]
<li>Easy Street (1917) [short]
<li>Rink, The (1916) [short]
<li>(none yet)
<li>(none yet)
<li>(none yet)
<li>(none yet)
<li>(none yet)</ol>
<b>Also Recommended: </b>Winsor McCay, the Famous Cartoonist of the
N.Y. Herald and His Moving Comics (1911) [short]; Cameraman's
Revenge, The (1912) [short]; Pool Sharks (1915) [short]; Tramp, The
(1915) [short]; Champion, The (1915) [short]; Ask Father (1919)
[short]; <b>Meh: </b>Last Days of Pompeii, The (1913); Intolerance
(1916); For His Son (1912) [short]; Aeroplane Flight and Wreck
(Piloted by M. Cody) (1910) [short]; Girl and Her Trust, The (1912)
[short]; Bangville Police (1913) [short]; By the Sea (1915) [short];
Butcher Boy, The (1917) [short]; Adventurer, The (1917) [short];
<b>Garbage: </b>
---------

What I want to do is fix it so that all instances of [movie title],
[leading article] are switched to [leading article] [movie title].

I turned wildcards on and did a find and replace using the following
values for starters:

Find (without quotes): "; *; The"
Replace (without quotes): "; The *"

But, apparently * only works as a wildcard in find, and not replace (I
ended up with "; The *").

Does anyone know how to use wild cards in find and replace correctly
to accomplish what I like? Then I will adapt whatever you can tell me
for use with other articles and positions of movie titles (for
example, after <li> and </b> instead of ;).

THANKS TO ANYONE WHO CAN HELP!!!!
 

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