ExtraString

More ways to manipulate strings.

Summary

Type
Function

Function

boolean? ToBoolean(string str)

Function

array Split(string str, string separator)

Function

boolean EndsWith(string str, string phrase)

Function

boolean StartsWith(string str, string phrase)

Methods

ToBoolean()

boolean? ToBoolean(string str)

Returns true if str is equal to the phrase "true" and false if it is equal to the phrase "false". Will return nil if neither conditions apply.

Split()

array Split(string str, str separator)

Splits a string into elements on an array based on the separator.

Example
local ExtraString = IsaacHelper.GetModule("ExtraString")

local str = "This is a cool string!"
local foo = ExtraString.Split(str, " ") -- Separate by space

-- This
-- is
-- a
-- cool
-- string!

EndsWith()

boolean EndsWith(string str, string phrase)

Returns true if str ends with phrase.

Example
local ExtraString = IsaacHelper.GetModule("ExtraString")

local str = "Hello, world!"
if ExtraString.EndsWith(str, "world!") then
    print("Hello, computer!")
end

StartsWith()

boolean StartsWith(string str, string phrase)

Returns true if str starts with phrase.

Last updated