I hope you can help me create a regex that will extract the image name from a url. I've been trying to create the regex for a couple of days now but i cant get it to work.
The case:
I have an image url created with phpThumb that looks like this:
\bla\thumb\phpThumb.php?src=/bla/images/thisistheimage.jpg&fltr[]=wmt|40|B|FFFFFF|georgia.ttf|35&hash=b7412f04f09cd6b488435231651d61453
No i need the following extracted: thisistheimage.jpg
Some facts:
All i have managed to grab was the image extension with (?:png|jpg|gif).
Can you please help me what regex I have to use in this case?
I'm able to use the regex in javascript or in PHP, where do you recommend it? (I use javascript to submit the form and the form action is done in PHP).
/\/([A-Z0-9_-]{1,}\.(?:png|jpg|gif|jpeg))/i
I think that should work. i flag for insensitive case
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With