Godot version: 3.2.3 stable
OS/device including version: Kubuntu 20.04
Issue description:
rstrip removes one character before the . when removing patterns such as file extension: "abc.tscn".rstrip(".tscn") outputs ab whereas it should output abc.
"abc.tscn".rstrip("tscn").rstrip(".")".tscn".rstrip(".tscn")Steps to reproduce:
extends EditorScript
func _run() -> void:
var s := "abc.tscn"
print(".tscn : " + s.rstrip(".tscn"))
print("tscn : " + s.rstrip("tscn"))
print("tscn then . : " + s.rstrip("tscn").rstrip("."))
This outputs:
.tscn : ab
tscn : abc.
tscn then . : abc
I don't think this is a bug. rstrip's parameter is a set of characters, not a pattern. So, it will remove the trailing characters that are included in the argument. In your first example, it removes the c because it is also included in the argument. Others also make sense this way.
rstrip's parameter is a set of characters, not a pattern
So that's why!

I guess the docs could be exlpicit about chars being a set of characters rather than a pattern.
The correct way is then to "abc.tscn".replace(".tscn", "")!
I suppose it would be beneficial to mention this in the docs.
I'll go to docs then. Thanks!
Most helpful comment
So that's why!
I guess the docs could be exlpicit about
charsbeing a set of characters rather than a pattern.The correct way is then to
"abc.tscn".replace(".tscn", "")!I suppose it would be beneficial to mention this in the docs.
I'll go to docs then. Thanks!