Why isn't my re.sub replacing the contents of my MS Word file?
scottcabit at gmail.com
scottcabit at gmail.com
Fri May 9 15:51:04 EDT 2014
Hi,
here is a snippet of code that opens a file (fn contains the path\name) and first tried to replace all endash, emdash etc characters with simple dash characters, before doing a search.
But the replaces are not having any effect. Obviously a syntax problem....wwhat silly thing am I doing wrong?
Thanks!
fn = 'z:\Documentation\Software'
def processdoc(fn,outfile):
fStr = open(fn, 'rb').read()
re.sub(b'‒','-',fStr)
re.sub(b'–','-',fStr)
re.sub(b'—','-',fStr)
re.sub(b'―','-',fStr)
re.sub(b'⸺','-',fStr)
re.sub(b'⸻','-',fStr)
re.sub(b'-','-',fStr)
re.sub(b'­','-',fStr)
More information about the Python-list
mailing list