help with looping, re.search, multiple indexing
Peter Otten
__peter__ at web.de
Fri Feb 16 17:21:36 EST 2007
Lance Hoffmeyer wrote:
> How do I add another index inside a re.search?
>
> I want to add
> for j in [96,97,98,99]
> BASE = re.search ...
> sh.Cells97...
> for i ....
>
> so that the Table 96 within the re.search(s) becomes Table 96, Table 97,
> Table 98, Table 99 but don't know how to add a second index within the
> re.search since I already have %char in match = re.search ... " %char,
> neuro ...
You can make format strings with an arbitrary number of values by providing
a tuple
r"Table %d.*?%s.*?\n.*?\d(.*?)\n.*?" % (j, char)
or a dict
r"Table %(table)d.*?%(char)s.*?\n.*?\d(.*?)\n.*?" % dict(table=j, char=char)
on the right side of the % operator.
http://docs.python.org/lib/typesseq-strings.html
Peter
More information about the Python-list
mailing list