Working with Strings

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JulioYagami

I need a way to “copy” a string to another but cutting it, because I need to code a RPG dialogue system.

I don’t found anything in the String docs.

JulioYagami | 2018-12-13 13:52

Sorry, but i do not understand. You have a variable with the string? so you want to copy it to another variable but that the original variable becomes empty? Or you have a string and you want to cut some part of it and assign to a variable?

p7f | 2018-12-13 14:25

:bust_in_silhouette: Reply From: SIsilicon

I don’t found anything in the String docs.

So I assume you have found the substr() function.

var text = "This is what you mean by cutting it. Right?"
var cut_down_text = text.substr(0, 21)
# The above variable would be "This is what you mean"

It was exactly what I’m looking for. Thanks for the answer.

JulioYagami | 2018-12-13 14:43