Skip to content

Commit

Permalink
Expose replace(Vector<String>, String) to script as replace_all
Browse files Browse the repository at this point in the history
  • Loading branch information
shana committed May 27, 2024
1 parent 60c35c4 commit 44235e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/variant/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,7 @@ static void _register_variant_builtin_methods() {
bind_string_method(format, sarray("values", "placeholder"), varray("{_}"));
bind_string_methodv(replace, static_cast<String (String::*)(const String &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray());
bind_string_methodv(replacen, static_cast<String (String::*)(const String &, const String &) const>(&String::replacen), sarray("what", "forwhat"), varray());
bind_string_methodv(replace_all, static_cast<String (String::*)(const Vector<String> &, const String &) const>(&String::replace), sarray("what", "forwhat"), varray());
bind_string_method(repeat, sarray("count"), varray());
bind_string_method(reverse, sarray(), varray());
bind_string_method(insert, sarray("position", "what"), varray());
Expand Down
8 changes: 8 additions & 0 deletions doc/classes/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,14 @@
Replaces all occurrences of [param what] inside the string with the given [param forwhat].
</description>
</method>
<method name="replace_all" qualifiers="const">
<return type="String" />
<param index="0" name="what" type="PackedStringArray" />
<param index="1" name="forwhat" type="String" />
<description>
Replaces all occurrences of all [param what] entries inside the string with the given [param forwhat]. This is more efficient than calling [code skip-lint]replace[/code] multiple times with different [param what] and the same [param forwhat].
</description>
</method>
<method name="replacen" qualifiers="const">
<return type="String" />
<param index="0" name="what" type="String" />
Expand Down
8 changes: 8 additions & 0 deletions doc/classes/StringName.xml
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,14 @@
Replaces all occurrences of [param what] inside the string with the given [param forwhat].
</description>
</method>
<method name="replace_all" qualifiers="const">
<return type="String" />
<param index="0" name="what" type="PackedStringArray" />
<param index="1" name="forwhat" type="String" />
<description>
Replaces all occurrences of all [param what] entries inside the string with the given [param forwhat]. This is more efficient than calling [code skip-lint]replace[/code] multiple times with different [param what] and the same [param forwhat].
</description>
</method>
<method name="replacen" qualifiers="const">
<return type="String" />
<param index="0" name="what" type="String" />
Expand Down

0 comments on commit 44235e5

Please sign in to comment.