How do I get the first,second ect. word from a string?

Get help using Construct 2

Post » Tue May 31, 2016 5:13 pm

Example: A string containing "Wolf B Online", and I want the string itself to be left alone, but I just want "Wolf" as an output.

or
"Tom Jones" > "Tom"
"two oclock" > "oclock"

Is this possible?
B
22
S
6
Posts: 21
Reputation: 1,321

Post » Tue May 31, 2016 5:25 pm

tokenat(src, index, separator)

In your case. You want to find the first word ....

tokenat("Wolf B Online", 0, " ") ... will return "Wolf" (seperator = a space character)

Second word ...

tokenat("Wolf B Online", 1, " ") ... will return "B"

As always, anywhere there is an index, it is zero based.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue May 31, 2016 10:13 pm

Thank you very much!
B
22
S
6
Posts: 21
Reputation: 1,321


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 58 guests