Help matching a pattern using regex

Discussion in 'Programming' started by kishore415, Sep 24, 2011.

  1. #1
    HI..

    I have the below content..

    
    <img src="some url"
           onmouseover="some function"
           onmouseout="somefunction">
    
    HTML:

    I want to extract src and functions from the above pattern...

    here is the code am using ..

    
    preg_match_all("/<img src=\"(.*?)\" onmouseover=\"(.*)\" onmouseout=\"(.*)\"/);
    
    PHP:
    It could not match as the onmouseover started in new line..can you please help me to match this...

    Thanks
     
    kishore415, Sep 24, 2011 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    before you do the preg_match_all remove all line feeds from the string

    ie

    
    $string = str_replace("\n",'',$string);
    
    
    PHP:
     
    stephan2307, Sep 26, 2011 IP