PDA

View Full Version : Use of Wildcards in Word Find



MWE
10-07-2008, 05:05 PM
I am using Word2003. I have not been able to get the "#" wildcard (single digit) to work in any wildcard use, e.g., Like, Find, etc. All other wildcard representations including groups and other neat stuff seems to work OK.

Is this unique to my implementation of Word2003 or are others experiencing this problem as well?

Oorang
10-07-2008, 08:24 PM
Try "?" instead of "#" :)

MWE
10-07-2008, 09:23 PM
Try "?" instead of "#" :)Thanks for the reply.

"?" is the wildcard for any character or digit so "?" does not accomplish what "#" is supposed to do. Assume I am looking for three characters followed by a dash and then 3 numbers, e.g., ABC-123. The search sequence should be "???-###". But if I use "???-???", that will find ABC-123, but it would also find ABC-DEF which is not what I want. The work around is to use "???-???" and then test that the last 3 characters are numeric. That is my current workaround, but per any documentation I have seen, Word is supposed to support "#"

Dave
10-07-2008, 10:43 PM
Not sure if I follow... Are you looking for any/every sequence or do you know any part of what you're looking for? I was thinking that if you know with certainty some part of what you're looking for, you could find it, expand the range to obtain the whole sequence, convert the range to a string variable and then simply evaluate the string. Just a thought. Dave

MWE
10-08-2008, 04:24 AM
Not sure if I follow... Are you looking for any/every sequence or do you know any part of what you're looking for? I was thinking that if you know with certainty some part of what you're looking for, you could find it, expand the range to obtain the whole sequence, convert the range to a string variable and then simply evaluate the string. Just a thought. DaveIn the particular case that prompted this thread, I am looking for a sequence that is a combination of alpha, numerics and special characters. Thanks for the reply. You are correct that your approach is possible and that is exactly what I am doing as a workaround. But, if "#" worked as it was supposed to, the extra effort (expanding the range, converting the range, testing for numeric section, etc) would not be required.

I can always find workarounds; my real question is if others have found that "#" did not seem to work. If so, I will stop trying to get it to work each time I have a new application:banghead:

EricFletcher
10-08-2008, 06:08 AM
I think you may be confusing the wildcard codes with a different application. To look for the pattern ABC-123, I would use a Find what pattern like this instead:

([A-Z]{3,})(-)([0-9]{3,})

This specifically looks for any 3 uppercase alphabetic characters followed by a hyphen and any 3 digits.

MWE
10-08-2008, 12:58 PM
I think you may be confusing the wildcard codes with a different application. To look for the pattern ABC-123, I would use a Find what pattern like this instead:

([A-Z]{3,})(-)([0-9]{3,})

This specifically looks for any 3 uppercase alphabetic characters followed by a hyphen and any 3 digits.thanks for the reply. You are correct that your pattern will find what I am looking for and it is certainly a way to do it. I should have taken that approach rather than the work around I am using.

That said, if you use VBA help to explore the Find, Like and similar procedures and then explore Wildcards, the "#" is clearly stated as a wildcard for a single digit (0-9).

EricFletcher
10-08-2008, 04:17 PM
That said, if you use VBA help to explore the Find, Like and similar procedures and then explore Wildcards, the "#" is clearly stated as a wildcard for a single digit (0-9).
I've never checked that (in part because VBA's Help doesn't work properly on my system), but it does seem odd. Without wildcards, a ^# pattern in Word's Find will look for a single digit, but certainly not without the carat. Perhaps the # on its own is only valid for use in VBA's Find or Like statements.

Word's Help has a list of the various wildcard options, but it isn't very clear, and there are much better resources online.

Oorang
10-08-2008, 07:21 PM
It should work as documented. Could you give an example of it not working as expected?

macropod
10-08-2008, 09:46 PM
Hi folks,

FWIW, the find string can be simplified to:
???-[0-9]{3,3}