Fortinet black logo

String Library

Copy Link
Copy Doc ID 42c4d1e2-47b9-11ea-9384-00505692583a:342280
Download PDF

String Library

The FortiADC OS supports only the Lua string library. All other libraries are disabled. The string library includes the following string-manipulation functions:

• String.byte(s, i)

• String.char(i1,i2…)

• String.dump(function)

• String.find(s, pattern)

• String.format

• String.gmatch

• String.gsub

• String.len

• String.lower

• String.match

• String.rep

• String.reverse

• String.sub

• String.upper

• String.starts_with

• String.end_with

• String.format

Like:

a=12

b=string.format(“%s, pi=%.4f”, a, 3.14);

• {s:byte(1,-1)}

Like:

str = “abc\1\2\0”

t={str:byte(1,-1)}

t is a table like an array to store the string.

t[1] is 97, t[2] is 98, t[3] is 99, t[4] is 1, t[5] is 2, t[6] is 0.

• {s:sub(1, 3)}

str="abcdefg"

String Library

The FortiADC OS supports only the Lua string library. All other libraries are disabled. The string library includes the following string-manipulation functions:

• String.byte(s, i)

• String.char(i1,i2…)

• String.dump(function)

• String.find(s, pattern)

• String.format

• String.gmatch

• String.gsub

• String.len

• String.lower

• String.match

• String.rep

• String.reverse

• String.sub

• String.upper

• String.starts_with

• String.end_with

• String.format

Like:

a=12

b=string.format(“%s, pi=%.4f”, a, 3.14);

• {s:byte(1,-1)}

Like:

str = “abc\1\2\0”

t={str:byte(1,-1)}

t is a table like an array to store the string.

t[1] is 97, t[2] is 98, t[3] is 99, t[4] is 1, t[5] is 2, t[6] is 0.

• {s:sub(1, 3)}

str="abcdefg"