How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread cricfan
I'm parsing a text file to extract word definitions. For example the input text file contains the following content: di.va.gate \'di_--v*-.ga_-t\ vb pas.sim \'pas-*m\ adv : here and there : THROUGHOUT I am trying to obtain words between two literal backslashes (\ .. \). I am not able to match wo

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > I'm parsing a text file to extract word definitions. For example the > input text file contains the following content: > > di.va.gate \'di_--v*-.ga_-t\ vb > pas.sim \'pas-*m\ adv : here and there : THROUGHOUT > > I am trying to obtain words between two literal backslash

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread George Sakkis
This should give you an idea of how to go about it (needs python 2.3 or newer): import re slashPattern = re.compile(r'\\(.*?)\\') for i,line in enumerate(file("parseinput")): print "line", i+1, match = slashPattern.search(line) if match: print "matched:", match.group(1) e