Info 2 Android ls and df parsing

Hey all together,

after a lot of searching and using Google for days with no really good results i created now my own reg-ex functions to parse some Android shell outputs. So i only want to share my functions coz i dun found something like that.

If u create a Android File-Explorer or something else like this u'll have to get the ls and df output in some situations, if u use C# like me this will be great for u.

here are my functions:

(command) ls -l
(command) busybox ls -aFl

Code:
Select Code
^(?<TYPE>(-|b|c|d|l|s|p){1})(?<PERM>(-|r|w|x|s|t){9})\s{1,}(?<INCLUDES>([0-9]){1,}\s{1,})?(?<OWNER>(.*?))\s{1,}(?<GROUP>(.*?))\s{1,}(?<ID>([0-9]){1,},\s{1,})?(?<SIZE>([0-9]){1,}\s{1,})?(?<DATE>(.*?))\s{1,}(?<TIME>([0-9]{2}.[0-9]{2}|[0-9]{4}))\s{1}(?<NAME>(.*?))(\s{1}->\s{1}(?<SYMLINK>(.*?)))?(?<SUBTYPE>(\*|/){1})?$
u can use it like

Code:
Select Code
GroupCollection groups = Regex.Match("the ls -l or busybox -aFl output line by line", @"^(?<TYPE>(-|b|c|d|l|s|p){1})(?<PERM>(-|r|w|x|s|t){9})\s{1,}(?<INCLUDES>([0-9]){1,}\s{1,})?(?<OWNER>(.*?))\s{1,}(?<GROUP>(.*?))\s{1,}(?<ID>([0-9]){1,},\s{1,})?(?<SIZE>([0-9]){1,}\s{1,})?(?<DATE>(.*?))\s{1,}(?<TIME>([0-9]{2}.[0-9]{2}|[0-9]{4}))\s{1}(?<NAME>(.*?))(\s{1}->\s{1}(?<SYMLINK>(.*?)))?(?<SUBTYPE>(\*|/){1})?$").Groups;
            string Type = groups["TYPE"].Value;
            string SubType = groups["SUBTYPE"].Value;
            string Perms = groups["PERM"].Value;
            string Owner = groups["OWNER"].Value;
            string Group = groups["GROUP"].Value;
            string Id = groups["ID"].Value;
            string Size = groups["SIZE"].Value;
            string Date = String.Join(" ", groups["DATE"].Value, groups["TIME"].Value);
            string Name = groups["NAME"].Value;
            string[] extTmp = Name.Split('.');
            string FileExtension = extTmp[extTmp.Length - 1];
            string SymPath = groups["SYMLINK"].Value;

(command) df
(command) busybox df -Pakh

Code:
Select Code
^(df:\s{1,})?(?<NAME>(.*?))(:\s{1,}(.*?))?(\s{1,}(?<SIZE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<USED>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<FREE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<BLOCKSIZE>([0-9]){1,}))?(\s{1,}(?<USE>([0-9]{1,})%))?(\s{1,}(?<PATH>(.*?)))?$
u can use it like

Code:
Select Code
GroupCollection groups = Regex.Match("the df or df -Pakh output line by line", @"^(df:\s{1,})?(?<NAME>(.*?))(:\s{1,}(.*?))?(\s{1,}(?<SIZE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<USED>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<FREE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}(?<BLOCKSIZE>([0-9]){1,}))?(\s{1,}(?<USE>([0-9]{1,})%))?(\s{1,}(?<PATH>(.*?)))?$").Groups;
            string Name = groups["NAME"].Value;
            string Size = groups["SIZE"].Value;
            string Used = groups["USED"].Value;
            string Free = groups["FREE"].Value;
            string BlockSize = groups["BLOCKSIZE"].Value;
            string Use = groups["USE"].Value;
            string Path = groups["PATH"].Value;

Hope this helps someone

Regards,
k1ll3r8e

HTC-Sensation 4G (z710e)
- NanD: S-OFF
- Firmware: 3.33.401.6
- H-Boot: 1.27.1111 (juopunutbear)
- Rom: CM11 with ION and 3.0 kernel
- Recovery: 4EXT Touch & 4EXT Recovery Updater
- Battery: Anker 1900 mAh


- HTC Sensation Stock 2.3.x - 4.0.x RUUs
- HTC Sensation XE Stock 4.0.x RUUs

My Projects
- [DEV] AndroidCtrl.dll (ADB/Fastboot Mini-Framework)



My FTP links are currently down, i switch to another ISP this will take a while (7 - 21 days, starting today 10.07.2014)