strings pattern matching

Hi,

i am having difficulty understanding how to check if a certain string exists in a file being read.

I tried reading and looking at the limited sample code i found, but i am not getting anyway.

Hi All,

I am trying to read a file after i GET it from a website.

When the file is read, look for a line that matches some words, then save that line into a variable.
May i know how i can do this?
I have tried the code below but i am not able to see the line i want being printed in the terminal.

Do you have a sample code that i could use? Hopefully with code that prints the content of the line to the mobile screen not the terminal screen.

Pls could i get someone to help me look at my code below?

  1. is this correct 

[lua]if file then[\lua]

or

[lua]if (file) then [\lua]

  1. if the line being read inside the file contains the words “Match Email addresses” i would like to put this line into a variable so i can print it to mobile screen.

does anyone have sample code for this?

Thanks,

ttee

  1. network.request( “http://lua-users.org/wiki/StringRecipes”, “GET”, networkListener,  params )
  2.  
  3.     print(tostring(myFile))
  4.         print(“hello”)
  5.     local contents = “”
  6.     local file = io.open( path, “r” )
  7.     if (file) then
  8.         – read all contents of file into a string
  9.         local contents = file:read( “*a” )
  10.         
  11.         for line in file:lines() do
  12. if line:match “Match Email addresses” then
  13. print( line )
  14. end
  15. end
  16.         io.close( file )
  17.         print(contents)
  18.  
  19.     else
  20.         print(“file not found”)
  21.     end
  22.         print(path)
  23.  
  24.         print(contents)
  25.  
  26.