easy regexp by user_1

def f(s,p):
    c=s[:1];h=1;d=s.find;l=[c]
    if''==s:print p;l=s
    if'Z'<c:h+=d(']');l=list(s[1:h-1])
    if'('==c:h+=d(')');l=s[1:h-1].split('|')
    if d('?')==h:h+=1;l=['']+l
    for j in l:f(s[h:],p+j)
f(raw_input(),'')

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

download

return to the top page