ID:713874
 
(See the best response by GhostAnime.)
Code:
mob/verb/Chat(t as text)


How would I find the 1st word said in a sentence if I used this?

I have a general idea but I am not sure if it would work.

Best response
Use copytext(). For the end position, instead of entering a number, use findtext() for that spot. The only case that this would not work as you want is if there are spaces at the beginning [you could start the position for findtext() at character 2 if you so wished])
First = copytext(..., 1, findtext(" ",...))
I'm assuming findtext() grabs the position of the first needle searching from left to right. Return everything to the left of the first space found.
proc/first_word(t)
var space = findtext(t, " ")
return space ? copytext(t, 1, space) : t
ok so I ran into another problem. I was able to find the 1st word. But how do I remove it from the text?
In response to Dj dovis
Now that you know how to find the first Space in a text string, all you need to do is apply your knowledge of copytext() and copy all the text AFTER the Space instead of before it. That will only take a tiny modification of the moot code I provided.
Alri and then all I do is send the text after the space. Just needed a bit of thinking thanks.
In response to Dj dovis
Do essentially the same thing except the value returned from findtext() [either used directly or stored in a variable as Kaiochao showed] + 1 is used for the starting position:
Rest = copytext(..., findtext(...) + 1)
The reason for the +1 is you want to start after the space.