fork(1) download
  1. function get_lines_with_text(inputstr, search)
  2. local t={}
  3. for str in string.gmatch(inputstr, "[^\n]*"..search.."[^\n]*") do
  4. table.insert(t, str)
  5. end
  6. return t
  7. end
  8.  
  9. local str = [[hello1 : hello01
  10. hello2 : hello02
  11. hello3 : hello03]]
  12.  
  13. for _, line in pairs(get_lines_with_text(str, "hello2")) do
  14. print(line)
  15. end
  16.  
Success #stdin #stdout 0.01s 5424KB
stdin
Standard input is empty
stdout
hello2 : hello02