#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Print text between to "characters"


    Hello,

    I'm new to perl and I would like to extract text between to strings. I would like to print all texts between <source> and </source> in a text file. The <source> and </source> could be on different rows.

    Ex1
    ====
    <source>Test</source>

    => print Text

    Ex2
    ====
    <source>Test1
    av test1</source>
    <source>Test2</source>

    => Print Test1
    av test1
    Test2


    Thanks
    Gustaf
  2. #2
  3. !~ /m$/
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    May 2004
    Location
    Reno, NV
    Posts
    4,257
    Rep Power
    1810
    Looks like an XML file. If it is, the best way is to use an XML parsing module like XML::Simple.

    If you want more help than that, please provide a sample file.

    You should not use a regular expression for a job like this.

IMN logo majestic logo threadwatch logo seochat tools logo