Word Find & Replace

G

Guest

I have multiple name Indexes in a Word document in the following format:
{XE "First Middle Last"}
{XE "First Last"}
{XE "First Middle Maiden Last"}
{XE "First Last Suffix"} (Jr., Sr. III)
etc.
I have been trying to find each group such as {XE "First Last"} and replace
with {XE "Last, First"} with a Find of XE "(*) (*)" and Replace of /2, /1.
The "Find" finds all of the names above, not just the ones with two names.
I suspect the wildcard * does not work because of the spaces.
Any help would be greatly appreciated.
Cob
 
J

Jay Freedman

I have multiple name Indexes in a Word document in the following format:
{XE "First Middle Last"}
{XE "First Last"}
{XE "First Middle Maiden Last"}
{XE "First Last Suffix"} (Jr., Sr. III)
etc.
I have been trying to find each group such as {XE "First Last"} and replace
with {XE "Last, First"} with a Find of XE "(*) (*)" and Replace of /2, /1.
The "Find" finds all of the names above, not just the ones with two names.
I suspect the wildcard * does not work because of the spaces.
Any help would be greatly appreciated.
Cob

The * wildcard is often a problem, because it's hard to predict what
it will match. In this case, the first (*) matches the First, then the
space matches, but the second (*) will match anything -- including
spaces -- up to the next quote.

Try this search string instead, noting that there is a space character
between each exclamation and the following bracket:

XE "([! ]@) ([! ]@)"

The expression [! ]@ matches any consecutive sequence of characters
that are not spaces.

The replacement string should be

XE "\2, \1"

See http://word.mvps.org/faqs/general/UsingWildcards.htm for more.
 
G

Guest

Works great - thanks. Cob

Jay Freedman said:
I have multiple name Indexes in a Word document in the following format:
{XE "First Middle Last"}
{XE "First Last"}
{XE "First Middle Maiden Last"}
{XE "First Last Suffix"} (Jr., Sr. III)
etc.
I have been trying to find each group such as {XE "First Last"} and replace
with {XE "Last, First"} with a Find of XE "(*) (*)" and Replace of /2, /1.
The "Find" finds all of the names above, not just the ones with two names.
I suspect the wildcard * does not work because of the spaces.
Any help would be greatly appreciated.
Cob

The * wildcard is often a problem, because it's hard to predict what
it will match. In this case, the first (*) matches the First, then the
space matches, but the second (*) will match anything -- including
spaces -- up to the next quote.

Try this search string instead, noting that there is a space character
between each exclamation and the following bracket:

XE "([! ]@) ([! ]@)"

The expression [! ]@ matches any consecutive sequence of characters
that are not spaces.

The replacement string should be

XE "\2, \1"

See http://word.mvps.org/faqs/general/UsingWildcards.htm for more.
 

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