Jump to content




[question] Searching through a file to find and change on line


  • You cannot reply to this topic
2 replies to this topic

#1 kotorone1

  • New Members
  • 20 posts

Posted 05 August 2012 - 05:20 AM

Hello,

I am trying to store data in a file in the format

name:password:integer

is it possible to write a function that searches through that file, finds that specific line, and can either copy it or change the line?

or is it easier to
myTable = {}
myTable[1] = textutils.serialize({name,password,integer})
myTable[2] = textutils.serialize({name,password,integer})
myTable[3] = textutils.serialize({name,password,integer})
et cetera, and search thru the table and look for the needed line, deserialize it and return a result?

Thanks,
~Matt

#2 Ponder

  • New Members
  • 49 posts

Posted 05 August 2012 - 12:15 PM

There are already function to do that in the Lua String API. They use Regular Expression, it is a bit tricky if you are not familiar with them, but you should check this out.

#3 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 10:16 AM

You could list the lines of a file then edit the single lines using string.sub
Something like that.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users