Functions

From Ketarin
Revision as of 17:55, 9 October 2010 by Tomorrow (talk | contribs)

Sometimes you might need a variable value just slightly modified. For such cases, you can use a couple of functions on variables (feel free to suggest more). They are used like this: {variablename:function:argument1:argument2}

directory Extracts the directory name of an URL/file path

empty Have the variable return an empty string always

ext Extracts the file extension (without dot) of an URL/file path

filename Returns the file name (with extension) from a file path

formatfilesize Nicely formats a file size (given in bytes)

multireplace Replaces multiple subjects within a string. Usage

multireplacei Replaces multiple subjects within a string (case insensitive). Usage

regex Returns the value which is matched by the regular expression (first argument). If groups exist, you can also select a group's value with the second argument. 0 is the whole match, 1 the first group, 2 the second group and so on.

regexreplace Replaces the content matched with the regular expression (first argument) with the second argument. The second argument may contain $n as references to groups of the regular expression.

replace Replaces all occurrences of argument1 with argument2

trim Removes all whitespace at the start and end of a variable. If an argument is given, all characters of that string will be removed.

trimstart Like trim, but only for the beginning of a word

trimend Like trim, but only for the end of a word

toupper Outputs only uppercase characters

tolower Outputs only lowercase characters

split Splits the variable content at each occurrence of the first argument and returns the part of the string with the number specified in the second argument (zero based)

startuppath Returns the startup path of the current Ketarin instance (without exe file)