![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
Need regular expression help
I got the following to match an image tag with a path beginning with a / and replace it with a variable called domain that ends with a /
$a = eregi_replace(" src=\"/"," src=\"$domain/",$a); I want to know how I can write one or more new lines to match a similar image tag path that does not begin with a / and does not begin with a http for example <img src="images/someimage.gif"> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
Why don't you just do this in .htaccess, or set a <base href=.../>? What you're trying to fix shouldn't really be done that way. However, you can src=\"(/?) to just assume another localized request.
If you really want a semi-decent way to grab and rewrite your links: Code:
$preg = "/[\s]+[^>]*?src[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/i"; preg_match_all($preg, $all_of_content_here, $outvar, PREG_PATTERN_ORDER); Code:
foreach ($outvar as $imgsrc) { if (eregi($domain, $imgsrc)) { // is complete } elseif (eregi("^/", $imgsrc)) { // starts with a / } else { // assume it's local } }
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Jun 2003
Location: Los Angeles, CA
Posts: 512
|
Thanks for the tips, trying now.
|
![]() |
![]() ![]() ![]() ![]() ![]() |