I am trying to parse file permissions using string-match. My code is,
(setq fmode (nth 8 (file-attributes "/Users/sk/a.js")))
(message "file mode is as, - %s" fmode)
(string-match "^.\\(...\\)\\(...\\)\\(...\\)$" fmode)
(message "User permission - %s" (match-string 1))
(message "Group permission - %s" (match-string 2))
(message "Others permission - %s" (match-string 3))
It outputs,
file mode is as, - -rw-r--r--
User permission - (se
Group permission - tq
Others permission - fmo
As one can see, instead of parsing the file mode string, -rw-r--r--
, string-match
parses the buffer contents from the beginning position.
My case is very similar to the documented example here, but i am clueless why it doesn't work?