User Tools

Site Tools


function_find

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

function_find [2018/08/07 11:40] (current)
Niek created
Line 1: Line 1:
 +<file lua find.lua>​
 +-- Copyright (C) 2018 CurlyMo & Niek
  
 +-- This Source Code Form is subject to the terms of the Mozilla Public
 +-- License, v. 2.0. If a copy of the MPL was not distributed with this
 +-- file, You can obtain one at http://​mozilla.org/​MPL/​2.0/​.
 +
 +local M = {}
 +
 +function M.run(a, b, c)
 + if a == nil or b == nil or c ~= nil then
 + error("​FIND requires two arguments"​)
 + return nil
 + end
 + local n = -1
 + local s = nil
 + local e = 0
 + repeat ​
 + s, e = string.find(a,​ b, e + 1)
 + n = n + 1
 + until s == nil
 + return n
 +end
 +
 +function M.info()
 + return {
 + name = "​FIND",​
 + version = "​1.0",​
 + reqversion = "​8.1.1",​
 + reqcommit = "​0"​
 + }
 +end
 +
 +return M
 +
 +</​file>​
function_find.txt ยท Last modified: 2018/08/07 11:40 by Niek