SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed in Regex Patterns

    <h3 style=" text-align: left; margin-top: 10px;">abcd</h3>

    I need to extract abcd ? How to extract it?

    I m using this code :
    Code:
    preg_match_all("/<h3 style=\" text-align: left;\" >(.*?)<\/h3>/i",$html, $n);
    But its not working.. Any help will be appreciated.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,055
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Parsing HTML with a regular expression is almost never a good idea.

    That said, try this:

    PHP Code:
    $matches null;
    $returnValue preg_match('/<h3 .*>(.*)<\\/h3>/''<h3 style=" text-align: left; margin-top: 10px;">abcd</h3>'$matches);
    print_r($matches); 


Tags for this Thread

Bookmarks

Posting Permissions

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