Walls192 Posted January 1, 2008 Share Posted January 1, 2008 How do you search for a specific term in a .txt file and then copy it to a seperate file. For example if I wanted to search for "<img src=" in a html file and then write the results into a seperate file. Link to comment Share on other sites More sharing options...
Bert Posted January 2, 2008 Share Posted January 2, 2008 The best method is to use StringRegExp. Look in the help file, and there is an good writeup on it. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
rasim Posted January 2, 2008 Share Posted January 2, 2008 How do you search for a specific term in a .txt file and then copy it to a seperate file. For example if I wanted to search for "<img src=" in a html file and then write the results into a seperate file. This? Dim $Source = FileRead("c:\Test\test.html") If @error Then MsgBox(16, "Error", "Unable to open file") Exit EndIf $Result = FileOpen(@ScriptDir & "\Out.txt", 1) $str = StringRegExp($Source, '(?i)<img src=.*"', 3) If Not IsArray($str) Then MsgBox(16, "Error", "Required string not found") Exit EndIf For $i = 0 To UBound($str) -1 FileWriteLine($Result, $str[$i]) Next FileClose($Source) FileClose($Result) Link to comment Share on other sites More sharing options...
Walls192 Posted January 2, 2008 Author Share Posted January 2, 2008 Thanks Rasim thats what I as looking for Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now