Thank you Marco!

Between your post and the other stuff I happened to find at the same time, I
got it working.  Turned out I was making it much more difficult than it had
to be.  I ended up with:

<?
$filename = "newexample.html";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));

$contents =
preg_replace("/(\")([A-z0-9]+(\/))*([A-z0-9]+)(\.)(jpg|gif)(\")/",
"\"http://www.blah.com/$4.$6\"";, $contents);

echo $contents;
fclose ($fd);
?>

Lo and behold, it works.  Thanks all!

Jen

--- Marco Tabini <[EMAIL PROTECTED]> wrote:
> Jennifer--
>
> A couple of things. eregi_replace does not have a
> limitation parameter,
> which means that if you use it *all* the strings
> that match your pattern
> will be replace with the new pattern. In your case,
> if I read your code
> correctly (and I may not--I'm doing this from
> memory), the eregi
> replacement you perform will change *all* the paths
> you have in your
> file, and not just the first one, which, I believe,
> is what you're
> looking for.
>
> Also, there shouldn't be any need to make the
> replacements one by one. A
> single replacement should be enough if all the
> original paths have to be
> transformed into the same URL.
>
> For example:
>
> ereg_replace ("{/images/}{test.(jpg|gif)}",
> "http://www.microsoft.com/images/\\2";, $t);
>
> This would replace any occurrence of "/images/*.gif"
> and "/images/*.jpg"
> to "http://www.microsoft.com/images/*.gif"; or *.jpg
> respectively (once
> again, double check my regex...doing this from
> memory). If you *do* need
> to change each occurrence individually, then you
> should use preg()
> instead, which uses Perl syntax and has a limitation
> parameter.
>
> Also--a minor thing and I'm sure you thought of it,
> but you're not
> saving the file at the end :-)
>
> Hope this helps.
>
> Cheers,
>
>
> Marco


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to