String-functions

String-functions are statically bound to "string" -namespace, except fromBase64 and toBase64, which require string-prefix All inputs area String-type. If output-type is other than String then it is explicitly written out.

substring($start, $end)

Substring cuts the given string from the given String. The $start -parameter is the start position, which is inclusive and $end is end-position, which is exclusive.

Example

length() <Number>

Length simply returns the length of the String.

Example

trim()

Trim removes the spaces from the start and at the end of the String.

Example

contains($value) <Boolean>

Contains function returns true if the value is found from the String, and false if not.

Example

matches($regex) <Boolean>

Matches function returns true if the regex matches the String, and false if not. Note that the regex must match the whole string. The regex syntax can be checked from here

Example

endsWith($value) <Boolean>

Endswith returns true if the String ends with the given value, and false if not.

Example

startsWith($value) <Boolean>

StartsWith returns true if the String starts with the given value, and false if not.

Example

lowerCase()

LowerCase converts the String into lower-case.

Example

upperCase()

UpperCase converts the String into upper-case.

Example

fromBase64($options <Object>)

FromBase64 converts the Base64 representation into String.

Accepts optional $options -object, which has "encoder" field with the supported values: "basic" or "urlsafe", and "padding" -field (Boolean) to add the padding character '=' at the end of result.

Example

toBase64($options <Object>)

toBase64 converts the String into Base64-representation.

Accepts optional $options -object, which has "encoder" field with the supported values: "basic" or "urlsafe", and "padding" -field (Boolean) to add the padding character '=' at the end of result.

Example

toBinary() <Binary>

string:ToBinary converts Operon String into Operon Binary-value.

Example

padLeft($padWith <String>, $padToLength <Number>)

PadLeft prefixes the input-String with the given String ($padWith) until its length is $padToLength.

Example

padRight($padWith <String>, $padToLength <Number)

PadRight postfixes the input-String with the given String ($padWith) until its length is $padToLength.

Example

search($value <String>) <Array>

Search allows to search the given String (parameter $value) from the input-String. The result Array contains the indexes of the found results.

Example

splitBy($value <String>) <Array>

SplitBy splits the String into parts decided by the parameter $value.

Example

strip() <String>

Strip removes white space from left and right side of the string.

Example

stripLeft() <String>

StripLeft removes white space from left side of the string.

Example

stripRight() <String>

StripRight removes white space from right side of the string.

Example

random($options <Object>)

Random returns a random string based on the given options.

Options

  • length <Number>
  • seed <Number>
  • allowedChars <Array>

Example

replaceFirst($search <String>, $replace <String>)

ReplaceFirst replaces the first occurance of the given $search-parameter with the parameter given in $replace.

Example

replaceAll($search <String>, $replace <String>)

ReplaceAll replaces all occurrences of the given $search-parameter with the parameter given in $replace.

Example

fromCodePoints()

FromCodePoints converts the numeric Unicode-codepoints from an Array into a String.

Example

toCodePoints() <Array>

ToCodePoints converts a String into numeric Unicode-codepoints Array.

Example

toPath() <Path>

string:toPath() converts input-String which represents a path into a true Path.

Example