[EMAIL PROTECTED] wrote:
> 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...?

Maybe you want
pat = re.compile(re.escape(userinput))

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to