Newbie question: matching
josh R
josh.reeves at gmail.com
Thu Apr 15 19:13:06 EDT 2004
Hi all,
I am trying to write some python to parse html code. I find it easier
to do in perl, but would like to learn some basic python. My code
looks like this:
line = "<tr>eat at joe's</tr><tr>or else</tr><tr>you'll starve</tr>"
so = re.compile("(\<tr\>.*?\<\\tr\>)")
foo=so.match(line)
print foo.groups()
I'd like to get an array of elements that looks like this:
array(0)= <tr>eat at joe's</tr>
array(1)= <tr>or else</tr>
array(2)= <tr>you'll starve</tr>
Could you please tell me the correct way to do the matching?
also, is there something similiar to perl's s/foo/bar/g?
Thanks!!!
Josh
More information about the Python-list
mailing list