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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
subString | string | The substring to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
anotherString | string | The string to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
prefix | string | The prefix to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
suffix | string | The suffix to be compared |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
boolean | True 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
subString | string | The substring to search for |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
subString | string | The substring to search for |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The index of the last occurence of the substring |
function length(string s) (int )
Returns the length of the specified string
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
s | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
int | The length of the specified string |
function replace(string mainString, string replacePattern, string replaceWith) (string )
Replaces all instances of the replacePattern string with the replaceWith string and returns the result
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
replacePattern | string | The pattern to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
function replaceAll(string mainString, string replacePattern, string replaceWith) (string )
Replaces each substring of the mainString that matches the given regular expression with the given replacement
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
replacePattern | string | The regular expression to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The 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 Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
replacePattern | string | The pattern to search for |
replaceWith | string | The replacement string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
function split(string mainString, string regex) (string[] )
Splits the string with the given regular expression to produce a string array.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
regex | string | The regex to split the string |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string[] | string[]: The split string array |
function subString(string mainString, int from, int to) (string )
Returns a new string that is the substring of the specified string
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
mainString | string | The original string argument |
from | int | The starting index |
to | int | The ending index |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived sub string |
function toBlob(string s, string encoding) (blob )
Converts string to a BLOB
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
s | string | b: string value to be converted |
encoding | string | Encoding to used in the conversion |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
blob | string: BLOB representation of the given String |
function toLowerCase(string s) (string )
Returns a string with all the characters converted to lowercase
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
s | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The string converted to lowercase |
function toUpperCase(string s) (string )
Returns a string with all the characters converted to uppercase
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
s | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The 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 Name | Data Type | Description |
---|---|---|
s | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
function unescape(string s) (string )
Returns an unescaped string by omitting the escape characters of the original string
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
s | string | The original string argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | The derived string |
function valueOf(any value) (string )
Returns a string representation of an integer argument
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
value | any | An integer argument |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | String representation of the specified integer argument |