regexp questoin

micklee74 at hotmail.com micklee74 at hotmail.com
Fri Jun 9 12:00:25 EDT 2006


hi

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 [-]

pat.findall(lines)

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...?
thanks




More information about the Python-list mailing list