Regular Expressions for grabbing tags in between tag.

Discussion in 'HTML & Website Design' started by email_id, Aug 25, 2006.

  1. #1
    Friends,

    Im stuck with this code for regex in perl, would really appreciate some help in going ahead.

    I have the following problem ahead.

    $content contains the array loaded from the file abc.txt

    $content =~ m|<tag1>(.*)<\/tag1>|g;
    $TAG1 = $1;

    $TAG1 should be containing:
    text1<br>
    text2<br>
    text3<br>
    text4<br>
    text5<br>

    abc.txt
    *******************
    <tag1>
    text1<br>
    text2<br>
    text3<br>
    text4<br>
    text5<br>
    </tag1>
    <tag2>
    .
    .
    .
    .
    </tag2>
    *******************

    Thanks in advance.
     
    email_id, Aug 25, 2006 IP
  2. blfast

    blfast Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You probably need the single-line modifier (s next to the g).
     
    blfast, Jan 26, 2007 IP