rtilley wrote: > Hi, > > While trying to better understand security descriptors on Windows. I've > been examining text-based security descriptors. I have the security > descriptors on individual lines stored in a text file. I want to break > these lines apart based on owner, group, dacl and sacl. These areas are > demarcated by O: G: D: and S: > > There are no spaces in the lines. How can I read each line so that each > area is broken out? I'd like output like this: > > O: details > G: details or NONE > D: details or NONE > S: details or NONE > > Here is an example SD: > O:owner_sidG:group_sidD:dacl_flags(string_ace1)(string_ace2)...(string_acen)S:sacl_flags(string_ace1)(string_ace2)...(string_acen) >
It's a pretty simple regex: >>> import re >>> s='O:owner_sidG:group_sidD:dacl_flags(string_ace1)(string_ace2)...(string_acen)S:sacl_flags(string_ace1)(string_ace2)...(string_acen)' >>> >>> m=re.search(r'O:(.*?)G:(.*?)D:(.*?)S:(.*)', s) >>> m.group(1,2,3,4) ('owner_sid', 'group_sid', 'dacl_flags(string_ace1)(string_ace2)...(string_acen)', 'sacl_flags(string_ace1)(string_ace2)...(string_acen)') -- http://mail.python.org/mailman/listinfo/python-list