How do I check if string contains text

Just started using Construct 2? Post your questions here

Post » Fri Apr 17, 2015 12:37 pm

Hello !

Maybe I did not searched with the proper words, but I cannot find a way to check if a string contains some text.
For example I would like an event like this one:
variable1 = "sometext"
if variable1 contains "text" return true.

Is this possible ?
B
6
Posts: 10
Reputation: 272

Post » Fri Apr 17, 2015 12:58 pm

From the manual:

https://www.scirra.com/manual/126/system-expressions

find(src, text)
Find the first index within src that text occurs, else returns -1.

so system compare two values : find(variable1, "text") is not -1

if the variable contains the text this condition will be true...
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Apr 17, 2015 1:23 pm

Image
B
63
S
23
G
7
Posts: 1,475
Reputation: 10,776

Post » Fri Apr 17, 2015 6:05 pm

Thank you littleStin tha'ts perfect !
I was looking in regex, but this was in fact much simplier.

Korbaach, that's interesting. This is much more complex, but it reveals some interesting tricks, thank you.
B
6
Posts: 10
Reputation: 272


Return to Beginner's Questions

Who is online

Users browsing this forum: didjridoo and 0 guests