String functions
Name | Description | Complexity |
contains(String, String): Boolean | Checks whether the string contains substring | 3 |
drop(String, Int): String | Drops the first n characters of a string | 20 |
dropRight(String, Int): String | Drops the last n characters of a string | 20 |
indexOf(String, String): Int|Unit | Returns the index of the first occurrence of a substring | 3 |
indexOf(String, String, Int): Int|Unit | Returns the index of the first occurrence of a substring after a certain index | 3 |
lastIndexOf(String, String): Int|Unit | Returns the index of the last occurrence of a substring | 3 |
lastindexOf(String, String, Int): Int|Unit | Returns the index of the last occurrence of a substring before a certain index | 3 |
makeString(List[String], String): String | Concatenates list strings adding a separator | 30 |
size(String): Int | Returns the size of a string | 1 |
split(String, String): List[String] | Splits a string delimited by a separator into a list of substrings | 75 |
take(String, Int): String | Takes the first n characters from a string | 20 |
takeRight(String, Int): String | Takes the last n characters from a string | 20 |
contains(String, String): Boolean
Checks whether the string contains substring.
Parameters
Parameter | Description |
haystack : String | String to search in |
needle : String | String to search for |
Examples
drop(String, Int): String
Drops the first n
characters of a string.
Parameters
Parameter | Description |
xs : String | The string |
number : Int | The number n |
Examples
dropRight(String, Int): String
Drops the last n
characters of a string.
Parameters
Parameter | Description |
xs : String | The string |
number : Int | The number n |
Examples
indexOf(String, String): Int|Unit
Returns the index of the first occurrence of a substring.
Parameters
Parameter | Description |
str : String | The string |
substr : String | The substring |
Examples
indexOf(String, String, Int): Int|Unit
Returns the index of the first occurrence of a substring after a certain index.
Parameters
Parameter | Description |
str : String | The string |
substr : String | The substring |
offset : Int | The index |
Examples
lastIndexOf(String, String): Int|Unit
Returns the index of the last occurrence of a substring.
Parameters
Parameter | Description |
str : String | The string |
substr : String | The substring |
Examples
lastIndexOf(String, String, Int): Int|Unit
Returns the index of the last occurrence of a substring before a certain index.
Parameters
Parameter | Description |
str : String | The string |
substr : String | The substring |
offset : Int | The index |
Examples
makeString(List[String], String): String
Concatenates list strings adding a separator.
Parameters
Parameter | Description |
arr : List[String] | List of strings to concatenate |
separator : String | Separator |
Example
size(String): Int
Returns the size of a string.
Parameters
Parameter | Description |
xs : String | The string |
Examples
split(String, String): List[String]
Splits a string delimited by a separator into a list of substrings.
Parameters
Parameter | Description |
str : String | The string |
separator : Int | The separator |
Examples
take(String, Int): String
Takes the first n
characters from a string.
Parameters
Parameter | Description |
xs : String | The string |
number : Int | The number n |
Examples
takeRight(String, Int): String
Takes the last n
characters from a string.
Parameters
Parameter | Description |
xs : String | The string |
number : Int | The number n |
Examples