SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict peterb's Avatar
    Join Date
    Jun 2003
    Location
    Athens, Greece
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_match_all and html

    Hello all,

    I am trying to use preg_match_all to eliminate some html code.

    PHP Code:
    preg_match_all('/<span class="news_home_list">(.*?)<br>(.*?)/<img src="\/images\/grammi.gif" width="100%" height="2px">(.*?)<\/span>.*?/s'$html$postsPREG_SET_ORDER); 
    I am receiving the following error message:
    Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '<' on line 97

    Before I received the error, the code was working but then I added:
    PHP Code:
    <br><img src="/images/grammi.gif" width="100%" height="2px"
    I tried adding escapes but it still gives me the same error.

    Can someone explain what I am doing wrong?

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    63 Post(s)
    Tagged
    0 Thread(s)
    The problem is that you're using a pattern delimiter (the /) accidentally within the regex.

    Code:
    <br>(.*?)/<img src="…
              ^
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    SitePoint Addict peterb's Avatar
    Join Date
    Jun 2003
    Location
    Athens, Greece
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks that worked. Now I can regain my sanity!


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
  •