From: Peter Zotov Date: 2011-03-01T21:28:59+09:00 Subject: Re: Automatic question generator libs in Ruby Language On Tue, 1 Mar 2011 20:02:13 +0900, Adam Prescott wrote: > > This could be a long rabbit hole. > Well, you've started this. Now I shall show you what a rabbit hole is ;) #encoding:utf-8 # requires 1.9 QUESTION_REGEXP = Regexp.compile(<<'END'.strip, Regexp::EXTENDED | Regexp::MULTILINE) (?\g[!?.]?\s*){0}(?\g[!?.]\s*){0}(?[^!.?']+?){0} (?(?["'])\g\k\g|束\g損\g|\g\g|){0} \g END def questions(para) questions = [] while para =~ QUESTION_REGEXP para = $' questions << $& if $&.strip[-1] == ?? end questions end TEXT = <<'END' Nested 'questions?' are supported. This is a text. A question? This 束kind?損 is supported too, really? The quotes 束"shall 'be" matching?'損? END p questions(TEXT) -- WBR, Peter Zotov. P.S. You definitely should run the code on a real ruby. It is somehow... curious.