mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Reimplement String.erase
This commit is contained in:
parent
49a196277f
commit
6fa4f71ca6
6 changed files with 30 additions and 0 deletions
|
@ -2840,6 +2840,12 @@ String String::insert(int p_at_pos, const String &p_string) const {
|
|||
return pre + p_string + post;
|
||||
}
|
||||
|
||||
String String::erase(int p_pos, int p_chars) const {
|
||||
ERR_FAIL_COND_V_MSG(p_pos < 0, "", vformat("Invalid starting position for `String.erase()`: %d. Starting position must be positive or zero.", p_pos));
|
||||
ERR_FAIL_COND_V_MSG(p_chars < 0, "", vformat("Invalid character count for `String.erase()`: %d. Character count must be positive or zero.", p_chars));
|
||||
return left(p_pos) + substr(p_pos + p_chars);
|
||||
}
|
||||
|
||||
String String::substr(int p_from, int p_chars) const {
|
||||
if (p_chars == -1) {
|
||||
p_chars = length() - p_from;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue