[Tutor] Help with regular expressions

Karthikesh Raju karthik at james.hut.fi
Fri Sep 3 08:51:04 CEST 2004


Hi All,

i am trying to craft a regular expression to do the following:

in a file say a.txt

a.txt

1 2 3 4 5
6 7 8 9 10
11 23 34 54 56

*** ( 3  5 ) ***

--------------------------------

Now i want to match the *** ( 3  5 ) *** line and load
3 in rows and 5 in columns.

Where should i start?

i tried

import re

p = re.compile('\( [0-9]+ [0-9]+ \)')
a = '( 3 5 )'
p.match(a)

didnt move a cm ....

warm regards

karthik


-----------------------------------------------------------------------
Karthikesh Raju,		    email: karthik at james.hut.fi
                                           karthikesh.raju at gmail.com
Researcher,			    http://www.cis.hut.fi/karthik
Helsinki University of Technology,  Tel: +358-9-451 5389
Laboratory of Comp. & Info. Sc.,    Fax: +358-9-451 3277
Department of Computer Sc.,
P.O Box 5400, FIN 02015 HUT,
Espoo, FINLAND
-----------------------------------------------------------------------


More information about the Tutor mailing list