Mid Function? Grab n# characters from String starting from x

Godot Version

4.2.1

Question

Hi, total newbie walking through tutorials, and this site, first post here.
Wondering if there is a function to extract a length of characters from a string, from a starting position?

The term is called Mid in VB6, I couldn’t see it in the help files or any variation of it. (I might be blind to new terminology.)

It looks like this in practice. ie: MyString = Mid(string, start, length)

VB reference:

Example:

MyString = "Mid Function Demo"    ' Create text string.
FirstWord = Mid(MyString, 1, 3)    ' Returns "Mid".
LastWord = Mid(MyString, 14, 4)    ' Returns "Demo".

I use this funciton a lot for data compression with SQL.
Many thanks if someone can point me to the GDScript term.

It’s String.substr()

1 Like

Ah that worked perfectly! Thank you very much! :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.