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
[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
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