Skip to reading
GDScript Programming & Godot

Trim()

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page
Code example
Trim(value: Variant) -> String

Remove whitespace from both ends of text.

Returns: String.

Code example
Trim("  key  ")

Contains()#

Code example
Contains(value: Variant, search: Variant, case_sensitive: bool = true) -> bool

Search text for a substring, optionally ignoring case.

Returns: Boolean.

Code example
Contains("Archive Door", "door", false)

Use Array.has or in for array membership; this helper converts inputs to String.

StartsWith()#

Code example
StartsWith(value: Variant, prefix: Variant, case_sensitive: bool = true) -> bool

Check the start of text.

Returns: Boolean.

Code example
StartsWith("open archive", "open ")

EndsWith()#

Code example
EndsWith(value: Variant, suffix: Variant, case_sensitive: bool = true) -> bool

Check the end of text.

Returns: Boolean.

Code example
EndsWith("notes.txt", ".txt")
Page 82 of 378Permalink
Go to page