Re: ignore special characters in python regex

2009-07-21 Thread Gabriel Genellina
En Tue, 21 Jul 2009 02:02:57 -0300, Astan Chee escribió: I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I

Re: ignore special characters in python regex

2009-07-21 Thread Astan Chee
I think the re.escape did the trick. to answer your questions: By "ignore" i meant instead of using non-alphanumeric characters that have special significance in regular expression (e.g. [|\]) and treat them as normal strings (i.e preceded by \), but since I don't know all the characters in reg

Re: ignore special characters in python regex

2009-07-20 Thread John Machin
On Jul 21, 3:02 pm, Astan Chee wrote: > Hi, > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? It would help if you were to

Re: ignore special characters in python regex

2009-07-20 Thread Frank Buss
Astan Chee wrote: > I'm reading text from a file (per line) and I want to do a regex using > these lines but I want the regex to ignore any special characters and > treat them like normal strings. > Is there a regex function that can do this? Maybe re.escape helps? -- Frank Buss, f...@frank-b

ignore special characters in python regex

2009-07-20 Thread Astan Chee
Hi, I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I have so far: fp = open('file.txt','r') notes = fp.readlines