On 11/04/2011 15:21, gkl wrote:
OK. So if I understood you correctly, given the following (actual) URLs http://beta.images.theglobeandmail.com/archive/01258/election_heads__1258993cl-3.jpg http://storage.canoe.ca/v1/dynamic_resize/?src=http://www.torontosun.com/news/decision2011/2011/04/06/300_harper_boring.jpg&size=248x186 the following pattern ^\s*.*\.([a-zA-z]{3})$ | ^\S*\?\S*\.([a-zA-z]{3})&.*$ should match them both. Am I correct?
First of all I notice that the src parameter in your second URL's query is now an absolute URL, whereas your first post had just a file name. Since we cannot anticipate how far and in which direction your problem may grow, it is your responsibility to present the entirety of the possibilities as you know them. Otherwise you will be engaging the world in a goose chase of the wildest sort. If you mean /^\s*.*\.([a-zA-z]{3})$ | ^\S*\?\S*\.([a-zA-z]{3})&.*$/ then you must apply the /x modifier, otherwise the spaces at the end of the first option and at the beginning of the second form part of the expressions. As far as I can think, /^\s*.*\.([a-zA-z]{3})$/ is exactly equivalent to /\.([a-zA-z]{3})$/ which, presumably as you intend, will match the first URL and capture 'jpg'. It will fail to match the second URL. While the first option seemed to be considering the possibility of irrelevant leading spaces, the second /^\S*\?\S*\.([a-zA-z]{3})&.*$/ is insisting on a sequence of non-spaces from the beginning of the string up to the last possible question mark. Then another sequence of non-spaces up to the last possible dot, followed by three alphas and an ampersand. The subsequent /.*$/ does nothing. I suggest to you that simply /.*\.([a-z]+)/i will match all of the four URLs you have posted so far, and capture from them exactly what you expect. Only you can know the full extent of your problem, and why you refuse the advice you have been offered. I will continue to try to help you. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/