jadog Posted February 7, 2011 Report Share Posted February 7, 2011 I am trying to get a match for the following url: http://modmii.googlecode.com/files/ModMii4.4.9.zip However, there is also a french version that I DON't want. It shows up first, so how do a create a regex statement that excludes the FR? The url that it keeps giving me is: http://modmii.googlecode.com/files/ModMii_FR_4.4.9.zip Any help would be appreciated! Thanks Link to comment Share on other sites More sharing options...
Tomorrow Posted February 7, 2011 Report Share Posted February 7, 2011 I am trying to get a match for the following url: http://modmii.googlecode.com/files/ModMii4.4.9.zip However, there is also a french version that I DON't want. It shows up first, so how do a create a regex statement that excludes the FR? The url that it keeps giving me is: http://modmii.googlecode.com/files/ModMii_FR_4.4.9.zip Any help would be appreciated! Thanks Im not very experienced with regex so Omni or someone else will problably soon post something much better but in the meantime: http://modmii.googlecode.com/files/.{0,11}.zip This will not capture the FR version because it has 15 characters between files/ and .zip where as the regex looks for maximum of 11 characters. Very...err simple regex Link to comment Share on other sites More sharing options...
jadog Posted February 7, 2011 Author Report Share Posted February 7, 2011 Thanks Tomorrow, that does the trick! Link to comment Share on other sites More sharing options...
shawn Posted February 7, 2011 Report Share Posted February 7, 2011 This will break when the numbers exceed 9 in any position. It's better to use a more explicit statement, such as: http://modmii\.googlecode\.com/files/ModMii[\d\.]+\.zip Link to comment Share on other sites More sharing options...
jadog Posted February 7, 2011 Author Report Share Posted February 7, 2011 Even better! Thank you!!! Link to comment Share on other sites More sharing options...
Omniferum Posted February 7, 2011 Report Share Posted February 7, 2011 http[^"'_]+\.zip Because life is fun Link to comment Share on other sites More sharing options...
jadog Posted February 7, 2011 Author Report Share Posted February 7, 2011 Wow, so many ways to use RegEx. Boggles my mind. I understand the first two, but could someone explain this part [^"'_] of Omni's code. Basically how each character within the brackets will function? Link to comment Share on other sites More sharing options...
Omniferum Posted February 7, 2011 Report Share Posted February 7, 2011 All it does is go start with http and end in .zip but no match the string if it contains " or ' or _ [] means match whatever is in the brackets doing [^] means anything in that brackets should not be matched. Link to comment Share on other sites More sharing options...
jadog Posted February 8, 2011 Author Report Share Posted February 8, 2011 Works perfect, but I have a question. I understand that using the ^ excludes any lines with the _ . But why do we have the ' and " signs in there as well? Thanks for helping me understand. Link to comment Share on other sites More sharing options...
Omniferum Posted February 8, 2011 Report Share Posted February 8, 2011 download tags are usually surrounded by either ' or " If the match 'included' them you would have an invalid download url It helps narrow down searches as they are characters that obviously cannot exist within a valid download URL Again most downloads start with either the = " ' characters Link to comment Share on other sites More sharing options...
jadog Posted February 8, 2011 Author Report Share Posted February 8, 2011 Thank you for explaining that. Makes sense. Just one more question. Is it possible to exclude a whole word without excluding those letters? In other words, can I exclude the word "Ketarin", but not exclude the letter K? Link to comment Share on other sites More sharing options...
Omniferum Posted February 8, 2011 Report Share Posted February 8, 2011 I do have a regex for newbies guide on here, fairly sure I explained these questions there. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now