How can I access only the beginning of a string?

Version 4.3

How can I access only the first part/digit of a string.
Example if I have “4x” what code can I write to make another variable only equal the first part of that or “4”?

From the godot docs:

print("i/am/example/hi".get_slice("/", 2)) # Prints "example"

or

var some_array = "One,Two,Three,Four".split(",", true, 2)

print(some_array.size()) # Prints 3
print(some_array[0])     # Prints "One"
print(some_array[1])     # Prints "Two"
print(some_array[2])     # Prints "Three,Four"

or if you know the first part of the string will just be one character,

var my_string = "hello_world"
print(my_string)  # Prints "hello_world"
print(my_string[0])  # Prints "h"
2 Likes

This works thank you for the help.