String Library
1.10.1¶
#include <std/string.pat>
Functions¶
std::string::length(str string) -> u128
¶
Calculates the length of a given string
Parameter |
Description |
---|---|
|
String to calculate the length of |
|
Length of |
std::print("Hello", " ", "World", " ", 42); // Logs "Hello World 42"
std::string::at(str string, u128 index) -> char
¶
Get a character at a given index withing a string
Parameter |
Description |
---|---|
|
String to index |
|
Index to read character from |
|
Character at |
std::string::substr(str string, u128 pos, u128 size) -> str
¶
Gets a substring of “string” starting at “pos” of size “size”
Parameter |
Description |
---|---|
|
String to index |
|
Starting position of substring |
|
Size of substring |
|
Substring |
std::string::parse_int(str string, u128 base) -> s128
1.10.1¶
Parses “string” passed into the function as an integer in base “base” and returns it
Parameter |
Description |
---|---|
|
String to parse |
|
Base of integer. Use 0 to use number prefix to determine base |
|
Parsed integer |
std::string::parse_float(str string) -> double
1.10.1¶
Parses “string” passed into the function as a float and returns it
Parameter |
Description |
---|---|
|
String to parse |
|
Parsed float |
std::string::to_string(auto x) -> str
1.10.1¶
Turns a integer, floating point, character or bool into a string
Parameter |
Description |
---|---|
|
Integral, floating point, character of bool value |
|
Representation of |
std::string::starts_with(str string, str part) -> bool
1.10.1¶
Checks if the string “string” starts with the string “part”
Parameter |
Description |
---|---|
|
String to inspect |
|
String to match at the beginning of |
|
True if the string |
std::string::ends_with(str string, str part) -> bool
1.10.1¶
Checks if the string “string” ends with the string “part”
Parameter |
Description |
---|---|
|
String to inspect |
|
String to match at the end of |
|
True if the string |
std::string::contains(str a, str b) -> bool
1.10.1¶
Checks if the string “string” ends with the string “part”
Parameter |
Description |
---|---|
|
String to inspect |
|
String to find in |
|
True if the string |
std::string::reverse(str string) -> str
1.12.0¶
Reverses the string “string”
Parameter |
Description |
---|---|
|
String to reverse |
|
Reversed version of |