Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Wildcards in Code Searches

8 views
Skip to first unread message

Rick Raisley

unread,
Jan 4, 2010, 4:03:31 PM1/4/10
to
I was searching in my code, changing places I used the leftmost 5 characters
to the leftmost 3 characters, and wondered if there is a tool available to
help:

Basically, I'm looking for "Left$(strName, 5)" and "Left$(strThisName, 5)",
etc. What I'd like to do is use a wildcard, like "Left$(*, 5)" to locate
anywhere I'm using the leftmost 5 characters. But I can't use wildcards
within the IDE, or, for that matter, most text searching programs I have
(like NotePad, WordPad or Word).

For another project, I was looking for "\??\" (any two characters with
backslashes on each side).

Is there a tool that I can use to search through code using wildcards? I'm
not talking about writing a program to do this; that I could do. I'm looking
for an existing text editing or text searching tool that would allow it. Or
maybe a way of using the tools I have that I don't know about! ;-) I've
tried using the wildcards option in Word, but not had much success. For
example, searching for "v:\*\????_*" should find "v:\10-11\1000_sh1_B.tif",
but it doesn't.

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net


Ralph

unread,
Jan 4, 2010, 5:09:40 PM1/4/10
to

Regular Expressions
http://www.regular-expressions.info/reference.html

How to use RegExp in Word will depend on the version of Office you are
using. There are many examples and tutorials availble on the web.

Frankly, go research the many dedicated programmer editors out there.

-ralph

Rick Rothstein

unread,
Jan 4, 2010, 5:22:30 PM1/4/10
to
You might be able to use this function...

Function AmbiguousInStr(TextString As String, Pattern As String, _
Optional Start As Long = 1) As Long
Dim X As Long
Do While Left(Pattern, 1) = "*"
Pattern = Mid(Pattern, 2)
Loop
For X = Start To Len(TextString)
If Mid(TextString, X) Like Pattern & "*" Then
AmbiguousInStr = X
Exit Function
End If
Next
End Function

The Pattern argument would be any valid Like operator Pattern. The function
will look for that pattern in the TextString argument and return the first
position in the string where that pattern exists. The optional Start
argument allows you to begin searching for the Pattern at that character
position within the TextString argument.

--
Rick (MVP - Excel)


"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:OeSvgFYj...@TK2MSFTNGP05.phx.gbl...

Nobody

unread,
Jan 4, 2010, 5:45:03 PM1/4/10
to
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:OeSvgFYj...@TK2MSFTNGP05.phx.gbl...

Have you tried VB's Find dialog? It has pattern search option, but limited.
MZTools also has the same thing. Beyond that, you need to use external
program. One such free program that adds syntax coloring is PSPad. It
supports regular expressions. I am not sure about the specific cases you
mentioned, but you could use 5 "?". As for "\??\", the "\" character may
have been considered as special character and needs to be doubled.

http://www.pspad.com/en/


Rick Raisley

unread,
Jan 5, 2010, 7:52:27 AM1/5/10
to
Thanks, Rick, but as I mentioned below, I'm not looking for a way to code
this, but rather a way to find text in my code.

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net

"Rick Rothstein" <rick.new...@NO.SPAMverizon.net> wrote in message
news:%23%237zcxYj...@TK2MSFTNGP05.phx.gbl...

Rick Raisley

unread,
Jan 5, 2010, 7:59:33 AM1/5/10
to
"Nobody" <nob...@nobody.com> wrote in message
news:Of7Ij%23YjKH...@TK2MSFTNGP04.phx.gbl...

<red face>
I can't believe I didn't try the Pattern Matching option! I guess I was
expecting terminology with Wildcard in it, and somehow didn't notice it.
Yes, it does do pretty much what I want it to. And the "\" is an escape
character, as you mention, and I have to use "\\" to actually find a
backslash when searching from Word. Also found a good web site on wildcard
searches in Word, etc:

http://www.gmayor.com/replace_using?wildcards.htm

Thanks for the answers that were apparently obvious to everyone but me.
First day back of the new year, after all!
</red face>

0 new messages