Searching a string and extract all occurancies of a substring

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nico Grubert

    #1

    Searching a string and extract all occurancies of a substring

    Hi there,

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

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

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

    Example text:
    This is a test. <link url="/www/folder" target="_self" title=""A test.
    <source id="box"><param eter key="path">/www/mydoc1</parameter></source>
    And I need to extraxt /www/mydoc1 and /www/mydoc2 from this text.
    <source id="box"><param eter 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

Working...