easy regexp by SeeNoEvil

def g(i):
 c=i[0:1];v=[c];n=0;f=i.find
 if"("==c:n=f(")");v=i[1:n].split("|")
 elif"["==c:n=f("]");v[:]=i[1:n]
 n+=1
 if"?"==i[n:n+1]:v=[""]+v;n+=1
 for h in v:
\x09for t in(i and g(i[n:])or[i]):yield h+t 
print'\n'.join(g(raw_input()))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page