Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Occhioverde

Members
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by Occhioverde

  1. On 25/12/2017 at 12:53 AM, Molinko said:
    
    local file_path = "/home/myFile.txt" -- # path to your file here
    local pattern = "match this" -- # your pattern to find
    local matches = {}
    
    local function contains(str, pattern)
      return string.match(str, pattern) and true or false
    end
    
    for line in io.lines(file_path) do
      if contains(line, pattern) then
        table.insert(matches, line)
      end
    end

    That should get you started. Feel free to ask more questions if you like :) 

    With this solution I managed to solve my problem. Thanks so much.

  2. Good morning.
    I have a problem with an operation to do in the LUA language:
    I have a file in which I have stored data, separated by line. I would need to read this file and store every line of this in an array, ignoring the first one.
    For example:

    array = {line2, line3, etc}


    Next, I would also need to compare each of these lines with a string, to check if it is contained, and I would need to know how to do both.
    Thanks in advance for the help.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.