Hi
I am trying to parse a URL to remove all chars before the last slash.
For example, I have this url :
file:///Users/bob/Library/Application%20Support/Corona%20Simulator/Insight_1.3.7-32A8603CB6D6FF75EE2DD19496F67C8E/Caches/about_seasons_13_mybestnews.html
I want to keep :
/about_seasons_13_mybestnews.html
I have made a small parser :
utils.cleanUrl = function ( urlAbsolute, myChar ) local lg = (string.len(urlAbsolute) -1 ) \* -1 local i = string.find(urlAbsolute, myChar, -35, true) local urlFiltered if i then urlFiltered = string.sub(urlAbsolute, i+1) else urlFiltered = urlAbsolute end return urlFiltered end
There is no bug but if the length of the URL changes too much, it does not work because of the -35 limits. I have put this limit because if I take too much of the string, lua returns the first slash encountered, which is not always the last one.
I can make a work around by parsing the string from the end one char by char but I am sure there is a regular expression to get that result.
Does a regExp expert online ?