WEB quick regular expression help

Discussion in 'OT Technology' started by DillDoe, Aug 11, 2009.

  1. DillDoe

    DillDoe Feels good mang

    Joined:
    Jan 16, 2004
    Messages:
    62,315
    Likes Received:
    46
    Location:
    dilldoe.organ
    trying to find all image in source with php regular expression, this is what I got so far

    preg_replace("(.*?)\.(jpg|jpeg)$", "blah blah", htmlcode);

    but keep getting " Unknown modifier '\' " error

    but that '\' is for the . before the extension.
     
  2. DillDoe

    DillDoe Feels good mang

    Joined:
    Jan 16, 2004
    Messages:
    62,315
    Likes Received:
    46
    Location:
    dilldoe.organ
    yeah, that does work, but I'm looking for just myimage.jpg

    basically I'm looking for a regex of *.jpg, which I can't seem to get
     
  3. DillDoe

    DillDoe Feels good mang

    Joined:
    Jan 16, 2004
    Messages:
    62,315
    Likes Received:
    46
    Location:
    dilldoe.organ
    xxx.jpg (xxx = varying filename)
    replace with thxxx.jpg for all instance, be it 'img src=xxx.jpg', (xxx.jpg), 'xxx.jpg', etc..

    worked it out to this now
    preg_replace('.*\.jpg', "th" '.*\.jpg', htmlcode)

    which search for *.jpg (right?)

    but I get this error: No ending delimiter '.'
     

Share This Page