LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.Parse - Split a character string in an array

number = lp.Parse('texte','array','token');

number = lp.Parse('texte','array','token',index);


The lp.Parse LUA function split a character string in an array by using a token


‘texte’    The character string to parse

‘array’   An empty array 

'token' The separator string use to split the string

index    Equal 1 if the index should start at 1 and is require to support ipairs(array) function.

Return Values

number        The number of sub string created.

Warning ! . LoriotPro LUA function returns indexed table starting at index 0. Usually LUA function returns table starting at index 1. This cas cause errors when using some management function of LUA.

array[0]…array[number-1]             An array of the IP adresses of the devices found. (or array[1]…array[number] if index)

nil          Return nil if an error occurs                                             


Example of parsing on the "this is a line of text" character string.

line="this a line of text"; 

           nb=lp.Parse(line,'array',' ');

            if nb then

                  for i=0,(nb-1) do




for jj=0,table.getn(array) do

lp.Print(string.format("[%s] \n",array[jj]));


nb=lp.Parse(line,'array',' ',1); 


for key,value in ipairs(array) do lp.Print("[",key,"] [",value,"]\n") end


lp parse lua