diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-08-14 16:13:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 16:13:34 +0200 |
commit | 7718b90d9237e7ef65557f3bfb89f771dc7459eb (patch) | |
tree | add24b9b6cfdd87d151f1d112b4c6740dcdf4b96 | |
parent | c3a57ddf03805e96e6c9a615e4032138a71c42e7 (diff) | |
parent | 2290cc622702b3b50e50238d63fdc7a9d98c7abe (diff) |
Merge pull request #20443 from AlexHolly/add-string-format-no-index
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 8717c14a6b..35cd27f7f3 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2788,7 +2788,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) { |