Link | lp_file_trimPath |
Author | Bil Corry |
Category | File |
Version | 8.5.x |
License | Public Domain |
Posted | 02 Sep 2006 |
Updated | 02 Sep 2006 |
More by this author... |
Returns a sanitized path that will never specify from harddisk root.
Requires [lp_string_split]
''; var:'paths' = (: '/this/that ', ' /this/ that/ ', '//this//../that//', '///this/that/ ', 'c://somedir/ ', ' c:\\this\\that\\', '/this/somefile.txt', 'c://somedir/this/somefile.txt' ); iterate: $paths, local:'path'; '"' #path '"'; '\t'; '"' (lp_file_trimpath:#path) '"'; '\r\n'; /iterate; ''; Returns: "/this/that " "/this/that" " /this/ that/ " "/this/that/" "//this//../that//" "/this/that/" "///this/that/ " "/this/that/" "c://somedir/ " "/somedir/" " c:\this\that\" "/this/that/" "/this/somefile.txt" "/this/somefile.txt" "c://somedir/this/somefile.txt" "/somedir/this/somefile.txt"
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
[ define_tag:'lp_file_trimPath', -description='Returns a sanitized path that will never specify from harddisk root.', -priority='replace', -required='path'; local:'newpath' = (string: #path); #newpath->(replace:'\\','/'); if: #newpath->(contains:':'); #newpath = (lp_string_split: #newpath, ':', 2)->(get:2); /if; #newpath = (string_replaceregexp: #newpath, -find="[^a-z0-9\\/\\!\\@\\#\\$\\%\\^\\&\\(\\)\\{\\}\\-\\=\\_\\+\\~\\`\\;\\'\\,\\.]", -replace='', -ignorecase); #newpath = (string_replaceregexp: #newpath, -find="\\.\\.+", -replace='..', -ignorecase); #newpath = (string_replaceregexp: #newpath, -find="/+", -replace='/', -ignorecase); return: #newpath; ]
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft