String
Some text.
Examples:
pipeline example {
val string = "Hello, world!";
}
Stub code in coreClasses.sdsstub
| class String {
/**
* Return the number of characters in the string.
*
* @example
* pipeline example {
* val length = "Hello, world!".length(); // 13
* }
*/
@Pure
@PythonMacro("len($this)")
fun length() -> length: Int
/**
* Check if the string contains the substring.
*
* @example
* pipeline example {
* val contains = "Hello, world!".contains("world!"); // true
* }
*/
@Pure
@PythonMacro("$substring in $this")
fun contains(substring: String) -> contains: Boolean
/**
* Check if the string ends with the suffix.
*
* @example
* pipeline example {
* val endsWith = "Hello, world!".endsWith("world!"); // true
* }
*/
@Pure
@PythonMacro("$this.endswith($suffix)")
fun endsWith(suffix: String) -> endsWith: Boolean
/**
* Check if the string starts with the prefix.
*
* @example
* pipeline example {
* val startsWith = "Hello, world!".startsWith("Hello"); // true
* }
*/
@Pure
@PythonMacro("$this.startswith($prefix)")
fun startsWith(prefix: String) -> startsWith: Boolean
/**
* Return the substring of the string starting at the start index up to but excluding the end index.
*
* @param start The start index (inclusive).
* @param end The end index (exclusive).
*
* @example
* pipeline example {
* val substring = "Hello, world!".substring(7, 12); // "world"
* }
*/
@Pure
@PythonMacro("$this[$start:$end]")
fun substring(start: Int = 0, end: Int = this.length()) -> substring: String
/**
* Return the index of the first occurrence of the substring in the string or -1 if the substring is not found.
*
* @example
* pipeline example {
* val index = "Hello, world!".indexOf("o"); // 4
* }
*/
@Pure
@PythonMacro("$this.find($substring)")
fun indexOf(substring: String) -> index: Int
/**
* Return the index of the last occurrence of the substring in the string or -1 if the substring is not found.
*
* @example
* pipeline example {
* val index = "Hello, world!".lastIndexOf("o"); // 8
* }
*/
@Pure
@PythonMacro("$this.rfind($substring)")
fun lastIndexOf(substring: String) -> index: Int
/**
* Replace all occurrences of the old substring with the new substring.
*
* @example
* pipeline example {
* val replacedString = "Hello, world!".replace("world", "Safe-DS"); // "Hello, Safe-DS!"
* }
*/
@Pure
@PythonMacro("$this.replace($old, $new)")
fun replace(old: String, new: String) -> replacedString: String
/**
* Repeat the string n times.
*
* @example
* pipeline example {
* val repeatedString = "Ha".repeat(3); // "HaHaHa"
* }
*/
@Pure
@PythonMacro("$this * $n")
fun repeat(n: Int) -> repeatedString: String
/**
* Split the string into parts using the separator.
*
* @example
* pipeline example {
* val parts = "a,b,c".split(","); // ["a", "b", "c"]
* }
*/
@Pure
@PythonMacro("$this.split($separator)")
fun split(separator: String) -> parts: List<String>
/**
* Trim leading and trailing whitespace from the string.
*
* @example
* pipeline example {
* val trimmed = " Hello, world! ".trim(); // "Hello, world!"
* }
*/
@Pure
@PythonMacro("$this.strip()")
fun trim() -> trimmed: String
/**
* Trim leading whitespace from the string.
*
* @example
* pipeline example {
* val trimmed = " Hello, world! ".trimStart(); // "Hello, world! "
* }
*/
@Pure
@PythonMacro("$this.lstrip()")
fun trimStart() -> trimmed: String
/**
* Trim trailing whitespace from the string.
*
* @example
* pipeline example {
* val trimmed = " Hello, world! ".trimEnd(); // " Hello, world!"
* }
*/
@Pure
@PythonMacro("$this.rstrip()")
fun trimEnd() -> trimmed: String
/**
* Normalize the casing of a string to make it suitable for case-insensitive matching. This is essentially a more
* aggressive form of lowercasing. For example, the German lowercase letter "ß" gets converted to "ss".
*
* Casefolding is described in section 3.13 of the [Unicode Standard](https://www.unicode.org/versions/latest/).
*
* @example
* pipeline example {
* val casefolded = "Hello, world!".toCasefolded(); // "hello, world!"
* }
*
* @example
* pipeline example {
* val casefolded = "Poststraße".toCasefolded(); // "poststrasse"
* }
*/
@Pure
@PythonMacro("$this.casefold()")
fun toCasefolded() -> casefolded: String
/**
* Convert the string to lowercase. Prefer {@link String.toCasefolded} for case-insensitive matching.
*
* Lowercasing is described in section 3.13 of the [Unicode Standard](https://www.unicode.org/versions/latest/).
*
* @example
* pipeline example {
* val lowercase = "Hello, world!".toLowercase(); // "hello, world!"
* }
*
* @example
* pipeline example {
* val lowercase = "Poststraße".toLowercase(); // "poststraße"
* }
*/
@Pure
@PythonMacro("$this.lower()")
fun toLowercase() -> lowercase: String
/**
* Convert the string to uppercase. Prefer {@link String.toCasefolded} for case-insensitive matching.
*
* Uppercasing is described in section 3.13 of the [Unicode Standard](https://www.unicode.org/versions/latest/).
*
* @example
* pipeline example {
* val uppercase = "Hello, world!".toUppercase(); // "HELLO, WORLD!"
* }
*
* @example
* pipeline example {
* val uppercase = "Poststraße".toUppercase(); // "POSTSTRASSE"
* }
*/
@Pure
@PythonMacro("$this.upper()")
fun toUppercase() -> uppercase: String
/**
* Parse the string to a floating-point number.
*
* @example
* pipeline example {
* val float = "1.0".toFloat(); // 1.0
* }
*/
@Pure
@PythonMacro("float($this)")
fun toFloat() -> float: Float
/**
* Parse the string to an integer.
*
* @param base The base of the integer.
*
* @example
* pipeline example {
* val int = "10".toInt(); // 10
* }
*
* @example
* pipeline example {
* val int = "10".toInt(base = 2); // 2
* }
*/
@Pure
@PythonMacro("int($this, $base)")
fun toInt(base: Int = 10) -> int: Int
}
|
contains
Check if the string contains the substring.
Parameters:
Name |
Type |
Description |
Default |
substring |
String |
- |
- |
Results:
Name |
Type |
Description |
contains |
Boolean |
- |
Examples:
pipeline example {
val contains = "Hello, world!".contains("world!"); // true
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$substring in $this")
fun contains(substring: String) -> contains: Boolean
|
endsWith
Check if the string ends with the suffix.
Parameters:
Name |
Type |
Description |
Default |
suffix |
String |
- |
- |
Results:
Name |
Type |
Description |
endsWith |
Boolean |
- |
Examples:
pipeline example {
val endsWith = "Hello, world!".endsWith("world!"); // true
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.endswith($suffix)")
fun endsWith(suffix: String) -> endsWith: Boolean
|
indexOf
Return the index of the first occurrence of the substring in the string or -1 if the substring is not found.
Parameters:
Name |
Type |
Description |
Default |
substring |
String |
- |
- |
Results:
Name |
Type |
Description |
index |
Int |
- |
Examples:
pipeline example {
val index = "Hello, world!".indexOf("o"); // 4
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.find($substring)")
fun indexOf(substring: String) -> index: Int
|
lastIndexOf
Return the index of the last occurrence of the substring in the string or -1 if the substring is not found.
Parameters:
Name |
Type |
Description |
Default |
substring |
String |
- |
- |
Results:
Name |
Type |
Description |
index |
Int |
- |
Examples:
pipeline example {
val index = "Hello, world!".lastIndexOf("o"); // 8
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.rfind($substring)")
fun lastIndexOf(substring: String) -> index: Int
|
length
Return the number of characters in the string.
Results:
Name |
Type |
Description |
length |
Int |
- |
Examples:
pipeline example {
val length = "Hello, world!".length(); // 13
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("len($this)")
fun length() -> length: Int
|
repeat
Repeat the string n times.
Parameters:
Name |
Type |
Description |
Default |
n |
Int |
- |
- |
Results:
Name |
Type |
Description |
repeatedString |
String |
- |
Examples:
pipeline example {
val repeatedString = "Ha".repeat(3); // "HaHaHa"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this * $n")
fun repeat(n: Int) -> repeatedString: String
|
replace
Replace all occurrences of the old substring with the new substring.
Parameters:
Results:
Name |
Type |
Description |
replacedString |
String |
- |
Examples:
pipeline example {
val replacedString = "Hello, world!".replace("world", "Safe-DS"); // "Hello, Safe-DS!"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.replace($old, $new)")
fun replace(old: String, new: String) -> replacedString: String
|
split
Split the string into parts using the separator.
Parameters:
Name |
Type |
Description |
Default |
separator |
String |
- |
- |
Results:
Examples:
pipeline example {
val parts = "a,b,c".split(","); // ["a", "b", "c"]
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.split($separator)")
fun split(separator: String) -> parts: List<String>
|
startsWith
Check if the string starts with the prefix.
Parameters:
Name |
Type |
Description |
Default |
prefix |
String |
- |
- |
Results:
Name |
Type |
Description |
startsWith |
Boolean |
- |
Examples:
pipeline example {
val startsWith = "Hello, world!".startsWith("Hello"); // true
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.startswith($prefix)")
fun startsWith(prefix: String) -> startsWith: Boolean
|
substring
Return the substring of the string starting at the start index up to but excluding the end index.
Parameters:
Name |
Type |
Description |
Default |
start |
Int |
The start index (inclusive). |
0 |
end |
Int |
The end index (exclusive). |
this.length() |
Results:
Name |
Type |
Description |
substring |
String |
- |
Examples:
pipeline example {
val substring = "Hello, world!".substring(7, 12); // "world"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this[$start:$end]")
fun substring(start: Int = 0, end: Int = this.length()) -> substring: String
|
toCasefolded
Normalize the casing of a string to make it suitable for case-insensitive matching. This is essentially a more
aggressive form of lowercasing. For example, the German lowercase letter "ß" gets converted to "ss".
Casefolding is described in section 3.13 of the Unicode Standard.
Results:
Name |
Type |
Description |
casefolded |
String |
- |
Examples:
pipeline example {
val casefolded = "Hello, world!".toCasefolded(); // "hello, world!"
}
pipeline example {
val casefolded = "Poststraße".toCasefolded(); // "poststrasse"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.casefold()")
fun toCasefolded() -> casefolded: String
|
toFloat
Parse the string to a floating-point number.
Results:
Name |
Type |
Description |
float |
Float |
- |
Examples:
pipeline example {
val float = "1.0".toFloat(); // 1.0
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("float($this)")
fun toFloat() -> float: Float
|
toInt
Parse the string to an integer.
Parameters:
Name |
Type |
Description |
Default |
base |
Int |
The base of the integer. |
10 |
Results:
Name |
Type |
Description |
int |
Int |
- |
Examples:
pipeline example {
val int = "10".toInt(); // 10
}
pipeline example {
val int = "10".toInt(base = 2); // 2
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("int($this, $base)")
fun toInt(base: Int = 10) -> int: Int
|
toLowercase
Convert the string to lowercase. Prefer String.toCasefolded for case-insensitive matching.
Lowercasing is described in section 3.13 of the Unicode Standard.
Results:
Name |
Type |
Description |
lowercase |
String |
- |
Examples:
pipeline example {
val lowercase = "Hello, world!".toLowercase(); // "hello, world!"
}
pipeline example {
val lowercase = "Poststraße".toLowercase(); // "poststraße"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.lower()")
fun toLowercase() -> lowercase: String
|
toUppercase
Convert the string to uppercase. Prefer String.toCasefolded for case-insensitive matching.
Uppercasing is described in section 3.13 of the Unicode Standard.
Results:
Name |
Type |
Description |
uppercase |
String |
- |
Examples:
pipeline example {
val uppercase = "Hello, world!".toUppercase(); // "HELLO, WORLD!"
}
pipeline example {
val uppercase = "Poststraße".toUppercase(); // "POSTSTRASSE"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.upper()")
fun toUppercase() -> uppercase: String
|
trim
Trim leading and trailing whitespace from the string.
Results:
Name |
Type |
Description |
trimmed |
String |
- |
Examples:
pipeline example {
val trimmed = " Hello, world! ".trim(); // "Hello, world!"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.strip()")
fun trim() -> trimmed: String
|
trimEnd
Trim trailing whitespace from the string.
Results:
Name |
Type |
Description |
trimmed |
String |
- |
Examples:
pipeline example {
val trimmed = " Hello, world! ".trimEnd(); // " Hello, world!"
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.rstrip()")
fun trimEnd() -> trimmed: String
|
trimStart
Trim leading whitespace from the string.
Results:
Name |
Type |
Description |
trimmed |
String |
- |
Examples:
pipeline example {
val trimmed = " Hello, world! ".trimStart(); // "Hello, world! "
}
Stub code in coreClasses.sdsstub
| @Pure
@PythonMacro("$this.lstrip()")
fun trimStart() -> trimmed: String
|