ID:195083
 
//Title: findTexts()
//Public domain.
//Contributed by: YMIHere


/*
It's just like findText() except it returns the first string it finds out of a
list (in the form of [pos];[string]). It could be useful for command line
parsing.
*/



proc/findTexts(haystack, list/needles, start=1, end=length(haystack))
while(start <= end)
for(var/needle in needles)
var/i
while(get_letter(haystack, start+i) == get_letter(needle, ++i))
if(i >= length(needle))
return "[start];[needle]"
start++

proc/get_letter(string, pos)
return ascii2text(text2ascii(string,pos))



///*

mob/verb/test()
src << findTexts("Should I move or just look around?",\
list("look","move")) // returns "10;move"
src << findTexts("I'm not going anywhere!",\
list("look","move")) // returns null

//*/