regexp questoin

micklee74 at micklee74 at
Fri Jun 9 18:00:25 CEST 2006


i created a script to ask user for an input that can be a pattern
right now, i use re to compile that pattern
pat = re.compile(r"%s" %(userinput) )  #userinput is passed from
command line argument
if the user key in a pattern , eg [-] ,  and my script will search some
lines that contains [-]


but the script produce some error: sre_constants.error: unexpected end
of regular expression

how can i successful catch  patterns such as "[-]" in my regexp
compilation where input is unknown...?

More information about the Python-list mailing list