pattern match
Max M
maxm at mxm.dk
Wed Apr 23 02:39:08 EDT 2003
Mitch MF Cummstain wrote:
> I just started using python and I need help with a
> pattern match.
>
> m = re.match("(.{30})(word)(.{30})",paragraph);
>
> I need to match 30 characters on each side of word. The problem word
> is getting treated as a string not a variable like I need it to. How
> can I make it treat word as a variable ?
Are you sure this is how you want to do it? Perhaps a simple slice can
do the trick. It's hard to know without an example string.
word = paragraph[31:word.rfind(')')]
Also you say you want word to be a variable. But in which way, and what
value should it hold?
--
hilsen/regards Max M Rasmussen, Denmark
http://www.futureport.dk/
Fremtiden, videnskab, skeptiscisme og transhumanisme
More information about the Python-list
mailing list