www.webdeveloper.com
Results 1 to 3 of 3

Thread: Preg_match help

  1. #1
    Join Date
    Oct 2005
    Location
    California
    Posts
    603

    Preg_match help

    I'm looking for the occurence of whatever is in between:
    <h2 class=abc><a href=" .... "

    Here's what I've tried to piece together, but it's not working:

    PHP Code:
    $pattern '/\[<h2 class=abc><a href=\"\] (.*) \[\"]/i';

    preg_match($pattern$data$matches);

    print_r($matches); 
    Any help?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,157
    PHP Code:
    $pattern '/<h2 class=abc><a href="([^"]+)"/i'
    Match would then be in $matches[1].
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2007
    Posts
    120
    may this help you..
    PHP Code:
    $pattern '/(<h2 class\=abc\>\<a href\=\")(.*?)(\"\>)/i';

    preg_match($pattern$data$matches);

    echo 
    $matches[2]; 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles