Asterisk is not working properly as wildcard

jmt356
SilverLounger
Posts: 2395
Joined: 28 Mar 2010, 01:49

Asterisk is not working properly as wildcard

Post by jmt356 »

Asterisk is not working properly as wildcard

According to https://support.office.com/en-us/articl ... 897c87b3f4" onclick="window.open(this.href);return false;, the asterisk (*) can be used in wildcard searches to match “any number of characters. You can use the asterisk (*) anywhere in a character string. wh* finds what, white, and why, but not awhile or watch.”

However, the asterisk only finds single characters for me when it is typed alone. When it is typed with other characters, it has no function at all. For example, in a document in which the word “what” is present, searching for “wh*” only turns up “wh”; it does not turn up “wha” or “what.”

How can I get wildcards to find any word that starts with “wh,” regardless of how many characters that word is?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78659
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Asterisk is not working properly as wildcard

Post by HansV »

* by itself is not useful; you have to use it within a search string. Even wh* is not useful because it does not specify where to stop. To find words starting with "wh", enter the following in the Find what box:

<wh*>

< specifies the start of a word, and > the end of a word.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2395
Joined: 28 Mar 2010, 01:49

Re: Asterisk is not working properly as wildcard

Post by jmt356 »

What code would I use to find:

Find:
; '[text]';

Where “text” represents any word or number of words, whether capitalized or lowercase.
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78659
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Asterisk is not working properly as wildcard

Post by HansV »

Since [ and ] have a special meaning when using wildcards, you have to specify them as \[ and \]:

; '\[*\]';
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2395
Joined: 28 Mar 2010, 01:49

Re: Asterisk is not working properly as wildcard

Post by jmt356 »

Why is it that when I tick "Search Wildcards" in the Find field, Word is unable to find
'Bob (Business Fax)';

When I search for
'Bob (Business Fax)';

?

When I untick "Search Wildcards," Word finds it without any issue.

What is a code that would find:
'Bob (Business Fax)';

Where "Bob" can be any name, including combinations of letters or numbers, of any length of characters, and can be comprised of more than one word?
Regards,

JMT

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Asterisk is not working properly as wildcard

Post by macropod »

It's not working because ( and ) are special characters, too. Any of the characters that delineate wildcard expressions require a preceding \ character if they're to be used literally. According, use:
Find = 'Bob \(Business Fax\)';

By extension, for a more generalised Find, you might use:
Find = '*\(Business Fax\)';
or:
Find = '[!\(\)']@\(Business Fax\)';
The second version is less prone to mismatches.
Paul Edstein
[Fmr MS MVP - Word]

jmt356
SilverLounger
Posts: 2395
Joined: 28 Mar 2010, 01:49

Re: Asterisk is not working properly as wildcard

Post by jmt356 »

The text in my document looks like this:

'Name 1'; 'Name 2'; 'Name 3 (Business Fax)';

I want to find only the following:
'Name 3 (Business Fax)';

However, there are several instances of this item, and "Name 3" varies in each instance, so I want to replace it with "*".

However, when I search for
'Name 3 \(Business Fax\)';

I get the following results:
'Name 1'; 'Name 2'; 'Name 3 (Business Fax)';
'Name 2'; 'Name 3 (Business Fax)';
'Name 3 (Business Fax)';

How can I limit the search to only the final result?
Regards,

JMT

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Asterisk is not working properly as wildcard

Post by macropod »

As I said, you could use:
Find = '[!\(\)']@\(Business Fax\)';
With:
'Name 1'; 'Name 2'; 'Name 3 (Business Fax)';
all that will be matched is:
'Name 3 (Business Fax)';
Paul Edstein
[Fmr MS MVP - Word]

jmt356
SilverLounger
Posts: 2395
Joined: 28 Mar 2010, 01:49

Re: Asterisk is not working properly as wildcard

Post by jmt356 »

Thank you Paul. I overlooked the second section of your earlier post. The code provided therein worked.
Regards,

JMT