Sign in to follow this  
Followers 0
Walls192

Search for a specific term

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



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)

Share this post


Link to post
Share on other sites

Thanks Rasim thats what I as looking for

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0