SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: pregmatch help

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2008
    Location
    Plano, TX
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pregmatch help

    preg_match('#img src="[^"]+"#i', $postRow.post_description, $matches)

    i'm using that code to pull an image out of a block of text in the db. but sometimes in the image it will be set up <img title="" src="blabla"> is it at all possible to set the preg match up to say something like if there is text between the img and src it's ok, use this img anyway? if so plz help. thanx.

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    '/img.*?src="[^"]+"/i' 
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2008
    Location
    Plano, TX
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANK YOU!!!! it works.

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Location
    sudo rm -rf /
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    '/<[^>]+img\s[^>]+src=["]?[\']?([^"]+[^\']+)["]?[\']?[^>]*\/>/i'

    haven't tested it but should work


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
  •