• Welcome to Valhalla Legends Archive.
 

Search text files

Started by brew, March 20, 2007, 06:57 PM

Previous topic - Next topic

brew

Is there any efficient and easy way to find a certain string in a file besides....

Dim asdf$
Open file For Input As #1
Do Until EOF(1)
Line Input #1, asdf
If asdf = "string" Then Goto Lol
Loop
Lol:
Close #1

which is what i have been using for all the while?
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

MyndFyre

Yes, you can use Regular Expressions.  Take a look at http://visualbasic.about.com/od/usingvbnet/l/blregexa.htm for a brief stint in their use in VB6 as well as http://www.regular-expressions.info/vb.html which as a site is a great reference for regex.

Regular expressions are also supported by the Microsoft .NET Platform and are consequently available in Visual Basic .NET.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

Or load the entire file using binary access read, and then use instr.

brew

Myndfyre, thanks for helping. RegExs look very interesting and i might use that... but it would still require me to open the file as binary in order to use it. and that's basically what reality said......
Quote from: [RealityRipple] on March 20, 2007, 07:25 PM
Or load the entire file using binary access read, and then use instr.
because somewhere in that article it goes on to state how InStr() and Like() (like is good, but it's only for ranges of ascii characters) are the only two native VB6 regex functions. SO my best bet is to do what reality said, open it in binary and use InStr() until i find more documentation about and gain deeper knowledge of regexes.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

Well, there is one ity bity problem with that method. Depending on the file you load, it will take more time, ram, and process usage.

UserLoser

Quote from: brew on March 20, 2007, 08:08 PM
Myndfyre, thanks for helping. RegExs look very interesting and i might use that... but it would still require me to open the file as binary in order to use it. and that's basically what reality said......
Quote from: [RealityRipple] on March 20, 2007, 07:25 PM
Or load the entire file using binary access read, and then use instr.
because somewhere in that article it goes on to state how InStr() and Like() (like is good, but it's only for ranges of ascii characters) are the only two native VB6 regex functions. SO my best bet is to do what reality said, open it in binary and use InStr() until i find more documentation about and gain deeper knowledge of regexes.

Note that Like isn't a function, it's an operator

brew

Its a crazy one! Infact, too crazy to be considered an operator! heh... it should be a function though.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P