Searching a string and extract all occurancies of a substring

Nico Grubert nicogrubert at gmail.com
Thu Aug 31 11:44:08 EDT 2006


Hi there,

in a text with no carriage returns I need to look for all occurancies of 
this string:

<source id="box"><parameter key="path">...</parameter></source>

The ... can contain different values. I need to extract the string 
between <source id="box"><parameter key="path"> and </parameter></source>.

Example text:
This is a test. <link url="/www/folder" target="_self" title=""> A test. 
<source id="box"><parameter key="path">/www/mydoc1</parameter></source> 
And I need to extraxt /www/mydoc1 and /www/mydoc2 from this text.
<source id="box"><parameter key="path">/foo/bar/doc</parameter></source>

 From this text I need to get a list with this:
  ["/www/mydoc1", "/foo/bar/doc"]

What's the best way to do this?


I'll need to use Python: 2.3.5

Thanks in advance,
Nico




More information about the Python-list mailing list