Function like InStr using wildcards? 
Author Message
 Function like InStr using wildcards?

         I am using VB 4. I need to create a function that is just like
InStr but can have wildcards for input. I need the
         position of the find in the text. I`ve tried using "like", and
searching certain blocks of text using a loop,(the strings I
         am searching for are usually from 6 to 11 characters and
contain wildcards)but this takes WAY to much time. The
         InStr is much faster but does not allow me to search using
wildcard characters...please help.



Tue, 08 Oct 2002 03:00:00 GMT  
 Function like InStr using wildcards?
Can you detail the type of search you're making?  There may be a more
optimal solution that doing pattern matching--VB or otherwise.


says...

Quote:

>          I am using VB 4. I need to create a function that is just like
> InStr but can have wildcards for input. I need the
>          position of the find in the text. I`ve tried using "like", and
> searching certain blocks of text using a loop,(the strings I
>          am searching for are usually from 6 to 11 characters and
> contain wildcards)but this takes WAY to much time. The
>          InStr is much faster but does not allow me to search using
> wildcard characters...please help.



Thu, 10 Oct 2002 03:00:00 GMT  
 Function like InStr using wildcards?
Grinder-Thanks for your time.
I am searching text files which contain approx 1200 random characters:
Ex.)
AGHTLCYRETOLOPNQB.....etc.(with no spaces between characters)
for patterns such as "LCYR" or "L?YR" or "L[PCRY]YR" where each of these
would return the position 5.
It helps when I use InStr initially to search for some beggining letters
however some of the search strings I need to find must begin with
wildcards. Here is an example of my latest attempt at a faster
search(But it is still too slow):

Ex.)  To search in MyText for RecogText where MyText=AGHTLCYRETOLOPNQB
and RecogText=TL?YR and StartLen=2 and RecogLen=5, see the following:

Call SearchFunc(RecogText$,StartLen%,RecogLen%)
'get search string, the number of beggining characters and it's length

Do While MyFind% < Len(MyText$)
                MyFind% = InStr(MyFind% + 1, MyText$, Mid(RecogText$, 1,
StartLen%))
                    If MyFind% = 0 Then
                        MyFind% = Len(MyText$)
                        MyFind% = 0
                        Exit Do
                    End If
                    If MyFind% > 0 Then
                        If Mid(MyText$, MyFind%, RecogLen%) Like
RecogText$ Then
                            Print #1, MyFind%
                        End If
                    End If
            Loop

MyFind% will return 3.

Thanks again for your time and help,
Lewis



Fri, 11 Oct 2002 03:00:00 GMT  
 Function like InStr using wildcards?
Hi Lewis,

Quote:
> It helps when I use InStr initially to search for some beggining letters
> however some of the search strings I need to find must begin with
> wildcards.

Check out http://www.stinga.com/sgregexp/sgregexp.htm -- although it's
designed for VBScript, it works with regular VB as well, and it's pretty
fast. As this is based on the GNU regexp code, you'll have to get used to
Unix-style regular expressions, but the included help files and samples
should get you up and running quickly.

'//mdb



Sat, 12 Oct 2002 03:00:00 GMT  
 Function like InStr using wildcards?
Michiel-
I am working with it now...what a great tool...
looks like this may be exactly what I was looking for, you have been an
extremely big help, thanks alot.
Lewis


Sat, 12 Oct 2002 03:00:00 GMT  
 Function like InStr using wildcards?
Use the MS RegExp-engine (regexp.dll). Look under
http://msdn.microsoft.com/scripting


Tue, 15 Oct 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Using wildcards with Instr?

2. Wildcard with instr

3. instr and wildcard

4. Using the Instr function

5. HELP: Using InStr function to create a list box

6. Find Text Function Using Wildcards

7. Visual Liking in .Net using TREE VIEW control

8. InStr Function Help

9. Instr function

10. Bug in INSTR function

11. InStr Function does not work if start position is skipped

12. Instr Function Explanation Anyone ???

 

 
Powered by phpBB® Forum Software