Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 1, 2026.

I am stumped. Need Regex help.

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

CrackFeed.Com

Account Closed
Impact
13
Ok I have a variable names $source that hold the HTML code from a remote page.

What I am trying to do is use preg_match_all along with a foreach loop with preg_replace in it to go through $source and grab all the substring in the img src="" tag. The issue I am having is that some have full paths and some have relative paths. I need to remove the path to the file and leave the filename only.

Has anyone got a snipet of code for me? Nothing I have tried does what I need, close but no cigar. Any other ideas that are more efficient? I don't want to use libraries or 3rd party code, because this is a personal vendeta between me and this dang script. LOL

Any help will be well appreciated and probably rewarded with a few bucks to paypal.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
Just throwing it out there, and I am sure you tried.

But could you not get a substring of the image file name alone by taking the url (whether it be relative or not) and take everything after the last '/' this would leave just the file name + extension, which you could remove by a similar process?

So.. get the URL.. sub string for everything after last '/'...substring before the '.' for the extension = filename.

Or did I miss something? :D
 
0
•••
Thanks for the reply!

Well I also need to gut out each url or path and keep that filename. There are anywhere from 15 to 50 thumbs per page. So I figured that preg_match_all would be the first thing to do, get them all into an array.

In case anyone is curious to the script: This script I created, creates large batches of galleries (15K batches) from various adult affiliate programs and generates them on my server with my affiliate codes and alters the html and content to be SEO. This issue is the last one I have and then I can run this full force. It also generates not jsut galleries for my site, but to all of my other sites as well. So, I can manage hundreds of thousands of galleries on multiple domains from one admin panel:)

So basically it takes hosted galleries from the affiliate programs and downloads all media and html and changes the html to meet my needs. So, no more having to generate galleries, this script will create a lifetime worth of them:) I already tested without the image downloading and such and I got 14,000 galleries generated in about an hour. But, one of the hosts uses anti-leech so I have to get the media too.
 
Last edited:
0
•••
Imperfect but could do the trick:
PHP:
$html='....................'

$pattern ='#(<img[^>]+src=")(?:[^/"]+/)*(?:([^"]+))(".*>)#i';
$replacement = '$1$2$3';
echo preg_replace($pattern, $replacement, $html);
 
0
•••
Thanks sdsinc I will try this later today and get back to you. That looks like it will do the trick!
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back