Im trying to extract text from a longer string to multiple strings and then I want to put them into an array with GDScript.
Also you may notice that the string (down below) is actually a Dictionary, if you know how I can replace an empty Dictionary with that string feel free to tell me because if so I wont have to extract those strings and that also would solve my problem.
...............................
The String: "{1:[Bones, 3], 30:[Iron Sword, 3]}"
Now I need to extract it like this "Bones, 3" > to array > "Iron Sword, 3" > to array
I looked through the String Documentation and I guess the only thing useful is ".rsplit()" but it will only look for one char and not two,
var some_string = "{1:[Bones, 3], 30:[Iron Sword, 3]}"
var some_array = some_string.rsplit("[", true, 1)
print(some_array.size()) # Prints 2
print(some_array[0]) # Prints "{1:[Bones, 3], 30:"
print(some_array[1]) # Prints "1:[Bones, 3], 30:[Iron Sword, 3]"
Then there is RegEx, I looked into it but before I try to learn its awkward syntax I thought I ask here if there is a relatively more easy way to "nab segments" of a long one liner string so that they can be put in an array, thanks in advance and I hope my question(s) is/are understandable.