LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
Loading...
Searching...
No Matches
string

Extra string functions (extends Lua's string library) More...

Detailed Description

These are added to Lua's standard string library, so like the other string functions, they can be called as methods on any string:

local file = "Picture.PNG"
print(file:endswith(".png")) -- false
print(file:endswith(".png", true)) -- true (ignoring upper/lower case)

Functions

boolean string.startswith (string str, string prefix, boolean ignorecase)
 
boolean string.endswith (string str, string suffix, boolean ignorecase)
 
table string.split (string str, string delimiters)
 

Function Documentation

◆ string.endswith()

boolean string.endswith ( string str,
string suffix,
boolean ignorecase )

Checks if a string ends with another string

Method form: str:endswith(suffix, ignorecase)

Parameters
strThe string to check
suffixThe end to look for
ignorecasetrue to ignore the difference between upper and lower case (optional, default: false)
Returns
true if str ends with suffix

◆ string.split()

table string.split ( string str,
string delimiters )

Splits a string into a list of parts. Every character of delimiters counts as a separator, and empty parts are skipped.

Method form: str:split(delimiters)

Parameters
strThe string to split
delimitersThe separator character(s) (optional, default: " ")
Returns
A list of the parts
Example:
local parts = ("ux0:data/myapp/save.txt"):split("/")
-- parts = {"ux0:data", "myapp", "save.txt"}
local words = ("one, two,three"):split(", ")
-- words = {"one", "two", "three"}

◆ string.startswith()

boolean string.startswith ( string str,
string prefix,
boolean ignorecase )

Checks if a string starts with another string

Method form: str:startswith(prefix, ignorecase)

Parameters
strThe string to check
prefixThe start to look for
ignorecasetrue to ignore the difference between upper and lower case (optional, default: false)
Returns
true if str starts with prefix