[BangPypers] Regular Expressions
nitin.nitp at gmail.com
Tue Mar 22 08:55:35 CET 2011
use this way
Its raw string stuff which i guess you are missing out.
On Wed, Mar 16, 2011 at 11:27 PM, Santhosh Edukulla <
santhosh.edukulla at gmail.com> wrote:
> Hi All,
> I have a list of regular expressions under a file(EX: inp.txt). Then, I
> 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.
> BangPypers mailing list
> BangPypers at python.org
More information about the BangPypers