Which function do i use to check if a string contains a phrase?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stubbsy345
:warning: Old Version Published before Godot 3 was released.

Probably very simple but I am quite new to GODOT. I have found it is possible to use ‘.find(“text”) != -1’ to do this but I’m wondering if there is a better way of doing this?

Thanks in advance.

:bust_in_silhouette: Reply From: whooshfrosted

There is the ‘in’ operator.

if string1 in string2:
do stuff

It is mentioned here:

Worked like a charm 4 years and your comment is still helping people :smiley:
Thanks for this lil trick :smiley:

MikeFozzy98 | 2021-12-01 00:41

It’s been 5 years, worked like a charm thank you so much.

Shineurysm | 2022-07-22 15:17

ok ok, six years! Thank you

grymjack | 2023-01-31 01:00