Subtract string variable

I am wondering if there is any action to trim a string variable. I understand that there are alternative ways but this is because it would be easier in my project.


we have the variable = “Hello world” and I want get only “Hello”. I imagine these 3 invented methods:

variable - “world”

this is Python: :sorriso_sudore:

that I know no. there are various alternatives (based on what you want to achieve)
For your example, in case you don’t know how long the word is to get, you can take one letter at a time and add it to the previous one until it meets the space (or another character)

an example is in this code: from a large variable it takes one character at a time and adds it to the previous one, until it finds the “” character so it understands that the word is finished and goes to the next one (in your case it would end there and would detect the first word)

There’s over a dozen string related expressions, including Substring (SubStr()).

Check out the Expression reference: Expressions reference [GDevelop wiki]

1 Like