
Parse a line of a directory list using splitstring and PCRE

andyfaff
Function/s parseDirectoryListLine(directoryline, isdirectory) string directoryline variable &isdirectory //directoryline = " dr-xr-xr-x 2 1 1 45056 Jan 6 20:11 q02ee8dddds" string a, b, c,d,e,f,g,h,i, j,k,l,m,n,o,p,q //perm string regex="([dwrx-]+)" //u regex+="(\\s)+" regex+="([[:alnum:][:punct:]]+)" //g regex+="(\\s)+" regex+="([[:alnum:][:punct:]]+)" //o regex+="(\\s)+" regex+="([[:alnum:][:punct:]]+)" //size regex+="(\\s)+" regex+="([[:digit:]]+)" //month regex+="(\\s)+" regex+="([[:alpha:]]{3})" //day regex+="(\\s)+" regex+="([[:digit:]]{1,2})" //time or year 00:00 or 2010 regex+="(\\s)+" regex+="([[:digit:]:]{4,5})" //filename/directory regex+="(\\s)+" regex+="(.+)$" splitstring/E=regex directoryline, a, b, c,d,e,f,g,h,i,j,k,l,m,n,o,p,q a = replacestring(" ", a, "") if(stringmatch(a[0], "d")) isdirectory = 1 endif return q End

Forum

Support

Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More