The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hello, everyone

For example, my instance is called @Instance@ID.

Is there a way to check if half of the name matches, then the result is true.

I think also to add in autoload, but there will be many types of instances.

What's your suggestion?

in Engine by (18 points)

2 Answers

+2 votes

You can use the String functions

begins_with()
ends_with()

If the string begins or end with the same string each time.

If it doesn't, then check out the RegEx class, in particular capturing groups to check if a string matches the regular expression and capturing sub-strings for id's and such.

by (388 points)
0 votes

Hi,
Also, if you just want to know your instance name has the word Instance in it, you can use in

Something like:

if "Instance" in object.name:
by (2,035 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.