Re: Who's up for a little game?
- Posted by ChrisB (moderator) Jan 17, 2011
- 2808 views
coconut said...
This program certainly need a function like that
include std/regex.e as re function ask(sequence prompt, sequence filter) /* print prompt and wait for an answer filter is a regular expression to filter answer */ re:regex valid_answer=re:new(filter,CASELESS) sequence answer puts(1,prompt) while 1 do answer=gets(0) answer=answer[1..$-1] if sequence(re:find(valid_answer,answer)) then exit else puts(1,"\ninvalid answer, try again\n"&prompt) end if end while return answer end function
Hi
To do what?
Chris