Search
 
SCRIPT & CODE EXAMPLE
 

LUA

lua string.split

function Split(s, delimiter)
    result = {};
    for match in (s..delimiter):gmatch("(.-)"..delimiter) do
        table.insert(result, match);
    end
    return result;
end

split_string = Split("Hello World!", " ")
-- split_string[1] = "Hello"
-- split_string[2] = "World!"
Comment

lua string split

function stringsplit(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t={}
	i=1
	for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
		t[i] = str i = i + 1
	end
	return t
end
Comment

lua split

-- Compatibility: Lua-5.1
function split(str, pat)
   local t = {}  -- NOTE: use {n = 0} in Lua-5.0
   local fpat = "(.-)" .. pat
   local last_end = 1
   local s, e, cap = str:find(fpat, 1)
   while s do
      if s ~= 1 or cap ~= "" then
         table.insert(t, cap)
      end
      last_end = e+1
      s, e, cap = str:find(fpat, last_end)
   end
   if last_end <= #str then
      cap = str:sub(last_end)
      table.insert(t, cap)
   end
   return t
end
Comment

PREVIOUS NEXT
Code Example
Lua :: local in script lua local 
Lua :: minetest lua delay 
Lua :: check if string is in string[] c# 
Lua :: while main.lua 
Lua :: lua how to make a click button 
Lua :: what is lua programming language 
Lua :: lua roblox hack scripts 
Lua :: Ackermann function lua 
Lua :: wails compile 
Lua :: how to enable https service roblox 
Lua :: animation event firing too many times roblox 
Matlab :: matlab count elements in matrix 
Matlab :: pyspark dense 
Matlab :: octave clear figure 
Matlab :: octave return dimensions 
Basic :: random numbers visual basic 
Basic :: dos assign command output to variable (when output is a single line) 
Elixir :: elixir length of list 
Elixir :: ** (Ecto.ConstraintError) constraint error when attempting to insert struct: * id_fkey (foreign_key_constraint) 
Elixir :: elixir variables 
Scala :: equivalent of spark datetype in scala 
Scala :: scala linters 
Excel :: Google Sheets How to Count the Days Between Two Dates 
Excel :: set row as header excel 
Perl :: Perl (perl 5.28.1) sample 
Pascal :: pascal loop 
Powershell :: ps where-object 
Abap :: abap data conversion 
Assembly :: regex find a word index of all matches 
Assembly :: irate translator 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =