Ballerina API Documentation

Functions of ballerina.lang.strings package

function contains(string mainString, string subString) (boolean )

Returns a Boolean value indicating whether a string contains the specified substring

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
subStringstringThe substring to be compared

Return Parameters:

Return VariableData TypeDescription
booleanTrue if the string contains the substring; false otherwise

function equalsIgnoreCase(string mainString, string anotherString) (boolean )

Compares two strings, ignoring the case of the strings

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
anotherStringstringThe string to be compared

Return Parameters:

Return VariableData TypeDescription
booleanTrue if the strings are equal; false otherwise

function hasPrefix(string mainString, string prefix) (boolean )

Returns a Boolean value indicating whether a string starts with the specified prefix

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
prefixstringThe prefix to be compared

Return Parameters:

Return VariableData TypeDescription
booleanTrue if the string starts with the prefix; false otherwise

function hasSuffix(string mainString, string suffix) (boolean )

Returns a Boolean value indicating whether the string ends with specified suffix

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
suffixstringThe suffix to be compared

Return Parameters:

Return VariableData TypeDescription
booleanTrue if the string ends with the suffix; false otherwise

function indexOf(string mainString, string subString) (int )

Returns the first index of the first occurence of the substring within the specified string

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
subStringstringThe substring to search for

Return Parameters:

Return VariableData TypeDescription
intThe index of the first occurence of the substring

function lastIndexOf(string mainString, string subString) (int )

Returns the first index of the last occurence of the substring within the specified string

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
subStringstringThe substring to search for

Return Parameters:

Return VariableData TypeDescription
intThe index of the last occurence of the substring

function length(string s) (int )

Returns the length of the specified string

Parameters:

Parameter NameData TypeDescription
sstringThe original string argument

Return Parameters:

Return VariableData TypeDescription
intThe length of the specified string

function replace(string mainString, string replacePattern, string replaceWith) (string )

Replaces the replacePattern string with the replaceWith string and returns the result

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
replacePatternstringThe pattern to search for
replaceWithstringThe replacement string

Return Parameters:

Return VariableData TypeDescription
stringThe derived string

function replaceAll(string mainString, string replacePattern, string replaceWith) (string )

Replaces all instances of the replacePattern with the replaceWith string and returns the result

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
replacePatternstringThe pattern to search for
replaceWithstringThe replacement string

Return Parameters:

Return VariableData TypeDescription
stringThe derived string

function replaceFirst(string mainString, string replacePattern, string replaceWith) (string )

Replaces the first instance of the replacePattern with the replaceWith string and returns the result

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
replacePatternstringThe pattern to search for
replaceWithstringThe replacement string

Return Parameters:

Return VariableData TypeDescription
stringThe derived string

function subString(string mainString, int from, int to) (string )

Returns a new string that is the substring of the specified string

Parameters:

Parameter NameData TypeDescription
mainStringstringThe original string argument
fromintThe starting index
tointThe ending index

Return Parameters:

Return VariableData TypeDescription
stringThe derived sub string

function toLowerCase(string s) (string )

Returns a string with all the characters converted to lowercase

Parameters:

Parameter NameData TypeDescription
sstringThe original string argument

Return Parameters:

Return VariableData TypeDescription
stringThe string converted to lowercase

function toUpperCase(string s) (string )

Returns a string with all the characters converted to uppercase

Parameters:

Parameter NameData TypeDescription
sstringThe original string argument

Return Parameters:

Return VariableData TypeDescription
stringThe string converted to uppercase

function trim(string s) (string )

Returns a trimmed string by omitting the leading and trailing whitespaces of the original string

Parameters:

Parameter NameData TypeDescription
sstringThe original string argument

Return Parameters:

Return VariableData TypeDescription
stringThe derived string

function unescape(string s) (string )

Returns an unescaped string by omitting the escape characters of the original string

Parameters:

Parameter NameData TypeDescription
sstringThe original string argument

Return Parameters:

Return VariableData TypeDescription
stringThe derived string

function valueOf(boolean b) (string )

Returns a string representation of a Boolean argument

Parameters:

Parameter NameData TypeDescription
bbooleanA Boolean argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified Boolean argument

function valueOf(double d) (string )

Returns a string representation of a double argument

Parameters:

Parameter NameData TypeDescription
ddoubleA double argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified double argument

function valueOf(float f) (string )

Returns a string representation of a float argument

Parameters:

Parameter NameData TypeDescription
ffloatA float argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified float argument

function valueOf(int i) (string )

Returns a string representation of an integer argument

Parameters:

Parameter NameData TypeDescription
iintAn integer argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified integer argument

function valueOf(json value) (string )

Returns a string representation of a JSON argument

Parameters:

Parameter NameData TypeDescription
valuejsonA JSON argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified JSON argument

function valueOf(long l) (string )

Returns a string representation of a long argument

Parameters:

Parameter NameData TypeDescription
llongA long argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified long argument

function valueOf(string s) (string )

Returns the string representation of a string argument

Parameters:

Parameter NameData TypeDescription
sstringThe specified string argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified string argument

function valueOf(xml e) (string )

Returns a string representation of an XML argument

Parameters:

Parameter NameData TypeDescription
exmlThe XML object argument

Return Parameters:

Return VariableData TypeDescription
stringString representation of the specified XML object


Menu

  • Functions
    • contains(string mainString, string subString) (boolean )
    • equalsIgnoreCase(string mainString, string anotherString) (boolean )
    • hasPrefix(string mainString, string prefix) (boolean )
    • hasSuffix(string mainString, string suffix) (boolean )
    • indexOf(string mainString, string subString) (int )
    • lastIndexOf(string mainString, string subString) (int )
    • length(string s) (int )
    • replace(string mainString, string replacePattern, string replaceWith) (string )
    • replaceAll(string mainString, string replacePattern, string replaceWith) (string )
    • replaceFirst(string mainString, string replacePattern, string replaceWith) (string )
    • subString(string mainString, int from, int to) (string )
    • toLowerCase(string s) (string )
    • toUpperCase(string s) (string )
    • trim(string s) (string )
    • unescape(string s) (string )
    • valueOf(boolean b) (string )
    • valueOf(double d) (string )
    • valueOf(float f) (string )
    • valueOf(int i) (string )
    • valueOf(json value) (string )
    • valueOf(long l) (string )
    • valueOf(string s) (string )
    • valueOf(xml e) (string )

Copyright 2017 Ballerina API Documentation