Guest Profpatsch Posted October 12, 2011 Report Share Posted October 12, 2011 I want to get a version name from a sourceforge-folder: URL: http://freefr.dl.sourceforge.net/project/dev-cpp/Binaries/Dev-C%2B%2B%20{ver}/devcpp-{ver}_setup.exe {ver}-URL: http://freefr.dl.sourceforge.net/project/dev-cpp/Binaries/?C=N;O=D URL-Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <title>Index of /project/dev-cpp/Binaries</title> </head> <body> <h1>Index of /project/dev-cpp/Binaries</h1> <ul><li><a href="/project/dev-cpp/"> Parent Directory</a></li> <li><a href="Dev-C++%20version%204.9.9.1/"> Dev-C++ version 4.9.9.1/</a></li> <li><a href="Dev-C++%20version%204.9.9.0/"> Dev-C++ version 4.9.9.0/</a></li> <li><a href="Dev-C++%20for%20Linux%200.7.0/"> Dev-C++ for Linux 0.7.0/</a></li> <li><a href="Dev-C++%204.9.9.2/"> Dev-C++ 4.9.9.2/</a></li> <li><a href="Dev-C++%204.9.8.0/"> Dev-C++ 4.9.8.0/</a></li> <li><a href="Dev-C++%204.9.7.0/"> Dev-C++ 4.9.7.0/</a></li> <li><a href="Dev-C++%204.9.6.0/"> Dev-C++ 4.9.6.0/</a></li> <li><a href="Dev-C++%204.9.5.0/"> Dev-C++ 4.9.5.0/</a></li> <li><a href="Dev-C++%204.9.4.1/"> Dev-C++ 4.9.4.1/</a></li> <li><a href="Dev-C++%204.9.4.0/"> Dev-C++ 4.9.4.0/</a></li> <li><a href="Dev-C++%204.9.3.0/"> Dev-C++ 4.9.3.0/</a></li> <li><a href="Dev-C++%204.9.2.0/"> Dev-C++ 4.9.2.0/</a></li> <li><a href="Dev-C++%204.9.1.0/"> Dev-C++ 4.9.1.0/</a></li> <li><a href="Dev-C++%204.0%20full%20package%20includes%20Mingw%20compiler/"> Dev-C++ 4.0 full package includes Mingw compiler/</a></li> <li><a href="4.01%20update/"> 4.01 update/</a></li> </ul> </body></html> Problem: There are the "version"-files and the "Linux"-file before the real version I want to get (4.9.9.2). My solution: Regex: (?<!(version%20))(?<! )\d\.\d\.\d\.\d The editor says it works (the version number is blue). But when I want to update it, it says: Dev-C++ with MinGW/GCC The downloaded file is not a binary file type (text/html; charset=utf-8). Possibly there is an error page. Status code: 200 (OK) (http://freefr.dl.sourceforge.net/project/dev-cpp/Binaries/Dev-C%2B%2B%20/devcpp-_setup.exe) Clearly, it hasn't included the version number. Did I do sth. wrong or is it a bug? Link to comment Share on other sites More sharing options...
floele Posted October 12, 2011 Report Share Posted October 12, 2011 Hm, hard to say. The issue occurs because in the editor it highlights the full regex match, while during download, it uses the value of the first group if multiple groups are used in the regular expression. I think it makes sense to adjust Ketarin to not use the first group, but the first group that contains a match. Any objections? Link to comment Share on other sites More sharing options...
Tomorrow Posted October 12, 2011 Report Share Posted October 12, 2011 My solution: Regex: (?<!(version%20))(?<! )\d\.\d\.\d\.\d Worked with this for me: (?<=Dev-C...20)[0-9a-zA-Z. ]{1,}(?=/) Link to comment Share on other sites More sharing options...
shawn Posted October 21, 2011 Report Share Posted October 21, 2011 This isn't a capturing regex: (?<!(version%20))(?<! )\d\.\d\.\d\.\d It's "matching" the text (blue) but it isn't CAPTURING the match that's desired (red). That requires a couple more para's, as so: (?<!(version%20))(?<! )(\d\.\d\.\d\.\d) Flo, I anticipate that change would likely cause problems, as it's not really how regex is intended. A "capture" isn't the same as a "match" and I don't think the difference should be muddled. If people are capable enough to use the system with regex, they should be encouraged to use a capture, not provide a lazy out for them - as that will almost assuredly result in more support requests trying to see why something that shouldnt match, is. Link to comment Share on other sites More sharing options...
floele Posted October 21, 2011 Report Share Posted October 21, 2011 Hm, already made the change in the beta, any problems? If not, I guess it's safe to do it this way for now. Link to comment Share on other sites More sharing options...
shawn Posted October 21, 2011 Report Share Posted October 21, 2011 Which (code) file is this in? I'll look at the code and try to create a situation where it would apply, and if it doesn't happen, it can be ignored. Link to comment Share on other sites More sharing options...
floele Posted October 21, 2011 Report Share Posted October 21, 2011 UrlVariable.cs, search for "// Use first group (except index 0, which is complete match) with a match" Link to comment Share on other sites More sharing options...
McNetic Posted March 1, 2012 Report Share Posted March 1, 2012 I think using the first group or the first group with a match is not the best way to do this at all. Sometimes, groups have to be used in regexes to find a match at all. It should in my opion possible to (might be optionally) manually select which group to be used. Link to comment Share on other sites More sharing options...
shawn Posted March 3, 2012 Report Share Posted March 3, 2012 Use a non-selecting group for anything prior or after the one you want to keep: (?:skip-this)(grab-this)(?:ignore_me) 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