StringUtils Class extending Object

/ The StringUtils class provides many methods to help manipulate strings within the marble language. These methods include the ability to split strings, get the length of strings, substr and more. A StringUtils object is created during the interpreter bootup so you can access this object directly with StringUtils.methodName(); /

Class Methods

Returns an ascii character from the Ascii table represented by the number provided

function getASCIIString(number n) : string


Returns a part of a string based on the position and total

function substr(string str, number pos, number size) : string

Returns the size of the provided string

function strlen(string str) : number


Returns the position of the needle in the haystack

function strpos(string haystack, string needle, number pos) : number

Splits the desired string and returns an array of strings

function split(string target, string delim) : string[]


Replaces all instances of to_replace from the target with the replace_with string

function str_replace(string target, string to_replace, string replace_with) : string

Matches all occurences in the target based on the regex string provided.
Returns a string array of all the occurences found

function preg_match_all(string target, string regex) : string[]


Trims whitespace from the left and right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target, string pattern) : string

Trims whitespace from the left and right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target, string pattern) : string


Trims whitespace from the left of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function trim(string target, string pattern) : string

Trims whitespace from the left of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function ltrim(string target, string pattern) : string


Trims whitespace from the right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function rtrim(string target, string pattern) : string

Trims whitespace from the right of the provided string target unless a pattern is provided
If a pattern is provided then the pattern is what is tripped from the string.

function rtrim(string target, string pattern) : string


Preforms a number format on the given target

function number_format(string target, number places) : string

Returns the given number as a correctly formatted string.
Whole numbers are returned as whole number strings. Doubles may have to be formatted correctly with the number_format function

function number_to_string(number val) : string


Makes the given value string html tag safe. Preventing XSS attacks
str_replace(val, "<", "<");
str_replace(val, ">", ">");

function safe_tags(string val) : string

Converts the given string to upper case and returns it.
Since: V0.2.0

function strtoupper(string val) : string


Converts the given string to lower case and returns it
Since: V0.2.0

function strtolower(string val) : string