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?
- is this correct
[lua]if file then[\lua]
or
[lua]if (file) then [\lua]
- 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
- network.request( “http://lua-users.org/wiki/StringRecipes”, “GET”, networkListener, params )
- print(tostring(myFile))
- print(“hello”)
- local contents = “”
- local file = io.open( path, “r” )
- if (file) then
- – read all contents of file into a string
- local contents = file:read( “*a” )
- for line in file:lines() do
- if line:match “Match Email addresses” then
- print( line )
- end
- end
- io.close( file )
- print(contents)
- else
- print(“file not found”)
- end
- print(path)
- print(contents)