johnsmith153 Posted November 27, 2012 Share Posted November 27, 2012 This: /[^\(]+\.(gif|jpg|jpeg|png|svg|bmp)[^;\s]*\)/gi ..runs quite slow. Any ideas to speed it up? Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/ Share on other sites More sharing options...
.josh Posted November 27, 2012 Share Posted November 27, 2012 it would help if you gave example content and exactly what you are trying to get out of it. Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/#findComment-1395641 Share on other sites More sharing options...
johnsmith153 Posted November 27, 2012 Author Share Posted November 27, 2012 Hi, Thanks for replying. My Regex is very poor and I put this together the best I can using various tutorials etc. If anything looks stupid then it probably is. It basically searches through a CSS file and returns an array of image URLs. That's all it needs to do. It doesn't need to to replace anything. It works, but takes ages to complete the processing. Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/#findComment-1395654 Share on other sites More sharing options...
.josh Posted November 27, 2012 Share Posted November 27, 2012 it would help if you gave example content and exactly what you are trying to get out of it. Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/#findComment-1395657 Share on other sites More sharing options...
johnsmith153 Posted November 27, 2012 Author Share Posted November 27, 2012 Example content: a CSS file, such as http://www.phpfreaks.com/media/css/screen.min.css It basically searches through a CSS file and returns an array of image URLs. Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/#findComment-1395660 Share on other sites More sharing options...
.josh Posted November 27, 2012 Share Posted November 27, 2012 Okay well, you still aren't being terribly helpful. I'm not much of a css person so I don't know all the syntax rules/possibilities for image URLs in a css file. Never assume that the context you are working with is common knowledge... Having said that..having a quick look at the "example" you provided, I would go with this: /url\s?\(([^)]*)/gi Quote Link to comment https://forums.phpfreaks.com/topic/271260-is-there-a-better-quicker-processing-way-to-write-this/#findComment-1395665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.