Newbie: text filtering.
Alan Gauld
alan.gauld at gssec.bt.co.uk
Mon Aug 7 12:03:23 EDT 2000
Aesop wrote:
> How could I go about say searching for the ".pdf", then working
> backwards to find the start of the word?
One approach would be to use regular expressions.
import re
....
match = re.search('\.pdf',line)
start = match.regs[0][0] # position of the '.' within line
while line[start] != ' ': # assume no spaces in filename!
start = start - 1 # decrement index
filename = line[start+1:match.regs[0][1]] # extract file name.
A starter maybe?
Alan G.
--
=================================================
This post represents the views of the author
and does not necessarily accurately represent
the views of BT.
More information about the Python-list
mailing list