1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Quick regex question for the real hardcore programers

Discussion in 'Programming' started by mumfry, Dec 2, 2011.

  1. #1
    hello

    i will get right into it
    how can i use regex to capture information from a file which has a layout like so

    <object>
    text here
    more text
    and some more text
    </object>

    my question is how can i use regex to get just the 3 lines between <object> and </object>

    i tried to do it like so

    preg_match("/<object>(.*)</object>/",$html,$vidid);

    by using (.*)

    but it didnt work at all

    i know that this might be simple to some of you...

    so please any help on this would be very much appreciated

    Thank you
     
    mumfry, Dec 2, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    mastermunj, Dec 3, 2011 IP
  3. mumfry

    mumfry Active Member

    Messages:
    118
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    thanks a lot master...
    that was certainly a step in the right direction.
    was so simple

    thanks again
     
    mumfry, Dec 3, 2011 IP
  4. DaveCS

    DaveCS Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Should be pretty simple.

    (^<object>)(.*)(</object>$)

    <object>
    text here
    more text
    and some more text
    </object>

    Check $2 and the result will be
    text here
    more text
    and some more text

    The only flags you will need for that regex is the dotall flag.
     
    DaveCS, Dec 14, 2011 IP