diff options
author | Alexander Holland <alexander.holland@live.de> | 2018-07-25 13:22:20 +0200 |
---|---|---|
committer | Alexander Holland <alexander.holland@live.de> | 2018-07-25 13:23:44 +0200 |
commit | 2290cc622702b3b50e50238d63fdc7a9d98c7abe (patch) | |
tree | 0f9b6e8d1c8ae7a0c9d6ba3c8ad8e5b2416cec23 | |
parent | 9e16f4a3704b76b3b7c236e29a141b3c33263667 (diff) | |
download | redot-engine-2290cc622702b3b50e50238d63fdc7a9d98c7abe.tar.gz |
Added String.format "no index" support
-rw-r--r-- | core/ustring.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 5f3858cb17..19ace9cc8a 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2781,7 +2781,11 @@ String String::format(const Variant &values, String placeholder) const { val = val.substr(1, val.length() - 2); } - new_string = new_string.replace(placeholder.replace("_", i_as_str), val); + if (placeholder.find("_") > -1) { + new_string = new_string.replace(placeholder.replace("_", i_as_str), val); + } else { + new_string = new_string.replace_first(placeholder, val); + } } } } else if (values.get_type() == Variant::DICTIONARY) { |