Keep single wildcard character unchanged when using Find and Replace in Word


When using the single-character wildcard ("?") in the Find & Replace box in Word, is there a way to leave the "single-character" unchanged during a multiple-instance replacement?

For example, suppose you have a lengthy document in which you want to [Replace All] strings consisting of a space followed by any single letter followed by a period followed by another space, ie:


where each underscore represents a space (just for the purposes of this post) and the x represents any single character.

And suppose you want to replace each of those strings with the following:


In other words, say you want to replace the period in the first string with a vertical bar but leave the single letter unchanged. Is there a way to do that?

I tried it using the single-character wildcard ("?") in both the Find and Replace field but that doesn't work so I'm curious to know if there is a workaround.

Who is Participating?
GrahamSkanConnect With a Mentor RetiredCommented:
Find: _(?)._
Replace: _\1|_
As in your convention, "_" represents a space.

The () brackets define a particular string in the Find part.
The \1 repeats the string found within the first pair of brackets in the find string. Any subsequent such strings can be defined by \2, \3, etc,
It is possible without a sample document, but it is always helpful to provide one. It reduces the work that the experts have to do to create an accurate one, and it increases the certainty that we understand the problem. Thank you.
Are there any restrictions on what the single character can be? For example, is another space acceptable?
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

WeThotUWasAToadConnect With a Mentor Author Commented:
Thanks a bunch Graham. This is awesome! I only wish I would have posted this question a long time ago. :P I'm always amazed at how much can be accomplished using just the Find and Replace box (in both Word & Excel) and this is a super addition to my toolkit. is always helpful to provide [a sample document]
Apologies for not including a sample doc. I actually thought about attaching something but I cannot post the doc to which I referred (due to its size and confidential content) and anything else, it seems, would have contained only a few strings, ie:


which I figured someone would likely create on their own if needed, rather than downloading and opening an attachment.

Are there any restrictions on what the single character can be? For example, is another space acceptable?
I was thinking only in terms of the 26 letters in the alphabet, not a space or other character.


I misinterpreted the next statement at first glance so these next notes do not contain a question but are just for my own future reference:
Any subsequent such strings can be defined by \2, \3, etc,
"subsequent such strings" is not referring to subsequent strings in the document but to subsequent strings in the Find and Replace arguments. For example,

Find what: _(?)._
Replace with: _\1|_

preserves a single character for every occurrence in a document even though the characters may be different (which is the whole point of this thread) so:

    {_A._ ; _B._ ; _C._ ; _D._ ; _E._} becomes {_A|_ ; _B|_ ; _C|_ ; _D|_ ; _E|_}


Find what: A B (*) 6 7 (?) 9
Replace with: A B \1 F G \2 I

    changes {A B C D E 6 7 H 9} to {A B C D E F G H I}

Note that it also works with * for multiple-character strings.
WeThotUWasAToadAuthor Commented:
Thanks again!
Thank you for your feedback.
Yes, it was easy to create a document. Questions can be somewhat ambiguous and a sample document can help to clarify. In this case your description was good.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.