Gozi Posted October 7, 2010 Report Share Posted October 7, 2010 Hi floele, what I´m trying to do is: Prefered method: - Loading an url - finding multiple strings with regex - saving the results in an array - using the array to generate a pool down menu - splitting a variable and getting the last part without knowing the split counts, or maybe getting the max count as command So I solved it for now: - Load an url - find the first match and save it in VAR "FirstMatch" - load the url one more time, find the end of first match and use it for Regex cursor to find second match - and so on - manual scripting the regex, cuz every app needs another method to get the last part Very complicated! In many cases It would be a great function to do not regex an url, but a variable and see what the hell I´m doing. ;-) Maybe I did not find the right way, but if it´s really missing, such function would be GREAT and would speed up the updates, cuz I could save a content in a variable without loading the url every time I need to run another regex. Any idea? Help me and I´ll give you the best SF-Template you´ve ever seen ;-) Link to comment Share on other sites More sharing options...
floele Posted October 7, 2010 Report Share Posted October 7, 2010 I'm not sure if I understand. You want to determine the last match of a regex applied on a URL's content? Link to comment Share on other sites More sharing options...
Gozi Posted October 7, 2010 Author Report Share Posted October 7, 2010 (edited) Ok. My fault to put too many request in one post. We´ve got a Variable "Test" with content Appname-irgendwas-nochwas-dir-version-Freeware-win32.exe I want the part Appname (ok easy), maybe the third one, and last one. As long as I know the max count, I could use {test:split:-:6} to get "win32.exe" for my needs. What I´m missing is a function like {test:split:-:last} which would let me grab this without knowing the part number and max count of splits. Another example (and thats what I want to use it for) is spliting a webpage with tables, classes and rows. I know the last class, or table or what ever can be defined with a <TAG> is what I need, but the max count of splits is unkown and alterates for different application (like Softpedia), or shown advertisements (many webpages). Next I put the different Classes in one Array {myArray:Regex1, Regex2,Regex3,........} Next I would regex the saved content of my array and not loading the url any more to extract desired information. But there´s no way to see what the result of my doing is, cuz in Ketarin we´re only able to regex an url and see the blue and red lines. Hopefully it´s now more clear? Alternatively I could explain it in german....would be much easier ;-) Edited October 7, 2010 by Gozi Link to comment Share on other sites More sharing options...
floele Posted October 7, 2010 Report Share Posted October 7, 2010 So {test:split:-:-1} would actually suffice? So negative numbers would count from the end of the array instead of the beginning. Link to comment Share on other sites More sharing options...
Gozi Posted October 7, 2010 Author Report Share Posted October 7, 2010 (edited) So, I just saw you´ve implemented the new split-function in the new Beta 9. Thats the better and more simplified way, as my thoughts for sure :-) THX a lot Edited October 11, 2010 by Gozi Link to comment Share on other sites More sharing options...
shawn Posted October 12, 2010 Report Share Posted October 12, 2010 The other option is to use something like this: {myvar:regex:\-([^\-]+)$} You can also regex pretty much any other variable to extract contents from it using that function...however, I would **really** love to have the ability to perform an XSL transform or use XSL selectors to obtain more specific info from HTML (like "slices" and such). Link to comment Share on other sites More sharing options...
floele Posted October 12, 2010 Report Share Posted October 12, 2010 XSL would only work on well formed XML I suppose, and this is only rarely the case for HTML pages. Link to comment Share on other sites More sharing options...
shawn Posted October 12, 2010 Report Share Posted October 12, 2010 Begin/End only works on certain HTML, too, though - so that's not really a good justification to exclude XSL. Even Regex is only useful if you can find a *unique* pattern that works for the specific data you're trying to capture. XSL is really a useful tool when it *can* work, and if it becomes an option within Ketarin, it could be very useful to those geeks like me that will find ways to make it work. Also, if it's implemented as a function, instead of only a capture type, we would be able to utilize it with well-formed data once we've mostly sanitized it using other methods. That said, I would really like the simplicity of using the IE "slice" method of simply tagging the returned region with an anchor reference in the URL. 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