Wildcard code to search for any number of characters

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

Wildcard code to search for any number of characters

Post by jmt356 »

What is the Wildcard code to find a bracket followed by the word "NOTE" followed by any number of characters until an end bracket? For example, I'd like to find these excerpts:

[NOTE: res ipsa loquitur res ipsa loquitur res ipsa loquitur res ipsa loquitur]

or

[NOTE: ipsa loquitur res ipsa loquitur res ipsa loquitur res ipsa loquitur res]
Regards,

JMT

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

Re: Wildcard code to search for any number of characters

Post by HansV »

Make sure that you tick the check box 'Use wildcards'. Enter the following in the 'Find what' box:

Code: Select all

\[NOTE: *\]
The \ before [ and ] is required because [ and ] have special meanings in a wildcard search. Preceding them with \ tells Word that you're searching for the literal characters [ and ].
S0250.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

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

Re: Wildcard code to search for any number of characters

Post by jmt356 »

It did not work for me. I think a single * tells Word I am looking for a single character only. However, I might need any number of characters before the ].
Regards,

JMT

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

Re: Wildcard code to search for any number of characters

Post by HansV »

No. ? is the wildcard for a single character, and * for any number of characters. I tested the expression in the screenshot, and it worked. Are you sure that you have ticked the 'Use wildcards' check box?
Best wishes,
Hans

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

Re: Wildcard code to search for any number of characters

Post by jmt356 »

Now it is working. I don't know why it was not working before; I had the Use wildcards ticked both times.

Thank you.
Regards,

JMT

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

Re: Wildcard code to search for any number of characters

Post by jmt356 »

If * searches any number of characters, why doesn't it find the word "an" or "and" when I search "a an and"? It is only finding individual letters, even when I have Wildcards selected.
Regards,

JMT

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

Re: Wildcard code to search for any number of characters

Post by macropod »

The wildcard expression posted by Hans (i.e. \[NOTE:*\]) is correct for the example you posted.

To find more than just the specified character(s) when using *, you have to give some indication of where to stop, otherwise a* erroneously might be expected to find all of "a an and" - and everything else in the document after the first 'a'. To find whole words "a" "an" & "and", you'd use: <a*>
Paul Edstein
[Fmr MS MVP - Word]