regex question

Does anyone know how I get can the quoted code into an array with just the filenames with PHP/regex.

desiered aray: array(0 => 'tn_21-b196054175f.jpg', 1 => 'tn_21-b196054175.jpg' ... n => 'nth_filename.jpg')

So basically the array just has the filenames from all of the <img> tags (the number of img tags varies, igoring the directory paths and the href.

Thanks!
<a rel="rokzoom" href="components/com_productbook/img_originals/21-b196054175f.jpg">
<img src="components/com_productbook/img_thumbnails/tn_21-b196054175f.jpg" alt="" /></a>
<a rel="rokzoom" href="components/com_productbook/img_originals/21-b196054175.jpg">
<img src="components/com_productbook/img_thumbnails/tn_21-b196054175.jpg" alt="" /></a>
.
.
.
<a rel="rokzoom" href="components/com_productbook/img_originals/nth_filename.jpg">
<img src="components/com_productbook/img_thumbnails/nth_filename.jpg" alt="" /></a>

Open in new window

LVL 1
burnsj2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tomasgruenerCommented:
Try to adapt following:
If you want to have the directory names:
src="([^.]*.jpg)"
If you just want to have the filenames try following pattern:
src=".*\/([^.|^\/]*.jpg)"

I tested it with your source snippet on http://www.regex-tester.de/regex.html and it worked fine
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tomasgruenerCommented:
Oh, I hope you are familiar a bit with regex, how you do the php specific stuff... i havent coded php since years and I'm not very sure, how to use regex on php. but that should be easy.
0
burnsj2Author Commented:
This does not seem to work with PHP who's regex's are perl compatible.

My current code:
preg_match_all('src=".*\/([^.|^\/]*.jpg)"',$note,$altResults,PREG_PATTERN_ORDER);
print_r($altResults);

where $note is the input text in the original question. print_r outputs: Array( )
0
burnsj2Author Commented:
This regex does seem to work on some platforms, so I'm closing this and will post for a PHP specifc answer.
Thanks,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.