[BangPypers] Regular Expressions

Santhosh Edukulla santhosh.edukulla at gmail.com
Wed Mar 16 18:57:24 CET 2011

Hi All,

I have a list of regular expressions under a file(EX: inp.txt). Then, I have
another file (EX: search.txt).The task is that i have to read the list of
regular expressions from the inp.txt and then search for the same in
"search.txt" and output the matched string.

Iam using python *"re" *module to do this.

This works except for few regular expressions below.

*a = '(/|\\)cmd\.com$'*

When i read the regular expression above from the file to a variable *(EX:
a)*. as below

Iam getting a different regular expresson as  *'(/|\\\\)cmd\.com$'*

2. Instead when i use *a.encode('string-escape')*, iam getting the output
for a as * '(/|\)cmd\.com$' *So when used like this, re.compile() statement
gives an error

Any idea to solve this.



More information about the BangPypers mailing list