How can I extract numbers from a string type?

var num_str: String = "HeartPart2"
var num: int = num_str.right(num_str.length()-9).to_int()
print(num)

You could replace the string line, and all the num_str’s with something like ‘node.name’ to get the the name from your nodes, assuming they all start with ‘HeartPart’ you just need to discard the first 9 characters.

Ryn

2 Likes