Searching a string and extract all occurancies of a substring

N

Nico Grubert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top