If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

It _looks_ like it allows anything except forward slash and left parenthesis, then a period, and one of six image formats, followed by anything that isn't a semi-colon or whitespace.

^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

It solves the processing speed problem, but doesn't quite get all the images.

It should sort through an entire CSS file and return all the images in that file (gif|jpg|jpeg|png|svg|bmp).

The problems are:

(1) it doesn't account for underscores So:
'image_name.png' is picked up as 'name.png'

(2) Numbers are ignored, so image_50.png is completely ignored

(3) It only gets the filename. So, '../images/filename.png' only returns 'filename.png'. Of course if the path is the same for all images in the stylesheet then that's fine, but it might not always be the case.

If doing it this way helps the speed problem then I can ensure that all images use the same path, but if it makes no difference to the speed then I'd like to get the full path.

aside, despite it's complexity, your whole posted code in #12 is still 3X slower than the one-liner i posted...

Yes, I am sure you are right. Yours could well be a few milliseconds faster. Who cares? I don't think my code is complex.

Also, mine has the merit that it works. I tested your one-liner with my string and got

stuff/mydirectory/images/xyz.jpg,../pqr_50.bmp

var newArr = imgUrls.filter(Boolean); is a feature of HTML5 so only works in the most modern browsers. Oddly enough some benighted people are still running IE7 or IE8. I feel that there is no point is coding which does not work in all reasonably expected browsers (say IE7+). Especially when the older code does just exactly the same thing. Like typing? Not really, but I am not bone idle either.

However, johnsmith153 (who for some reason is said to be infamous around these parts) seems to be happy, so I shall regard this thread as closed.

Last edited by Philip M; 11-28-2012 at 04:53 PM.
Reason: Correction

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

mine has the merit that it works. I tested your one-liner with my string and got

stuff/mydirectory/images/xyz.jpg,../pqr_50.bmp

var newArr = imgUrls.filter(Boolean); is a feature of HTML5 so only works in the most modern browsers. Oddly enough some benighted people are still running IE7 or IE8. I feel that there is no point is coding which does not work in all reasonably expected browsers (say IE7+). Especially when the older code does just exactly the same thing. Like typing? Not really, but I am not bone idle either.

um, the regexp is for CSS, not self-made-up testcases of url-ish junk. mine finds all the ones that the orig code does in the heap of css i tested:

the old what about 3-versions-behind IE users? i expected it.
this is an ECMA5 thing, not a HTML5 thing. why would HTML spec a core JS method anyway; that doesn't make sense... it's really from prototype.js, but better than that library's version because of the 2nd this argument.
i really think that average coders can shim such basic backwards-compatibility if need be. maybe it is asking too much, i'll consider it. Then again, someone around here always seems to stick up for the 5 year old browser crowd...

either way, no harm, a simple drop in can support all the way back to IE4 if need be:

even with the compat dropin (which nobody types), the combined code is still shorter than doing it the loopy way.

i really can't live without map/filter, so i don't understand how anyone doing any data processing would want to skip over that incredibly useful set of functionality. that's just me. It's the best thing to happen to JS since new Date().getFullYear()...

if you want to safely live in the luxury of functional coding, include fallback compat drop-ins with your standard library.