Best Regex Expression to manipulate my string

Hello guys, good afternoon.

I’m trying to manipulate a string with a proper regex expression but without success!

Original String:

df -i
Filesystem                    Inodes  IUsed    IFree IUse% Mounted on
/dev/mapper/vg0-rootvol       719488  42967   676521    6% /
devtmpfs                     4093600    436  4093164    1% /dev
tmpfs                        4096453      1  4096452    1% /dev/shm
tmpfs                        4096453   1384  4095069    1% /run
tmpfs                        4096453     16  4096437    1% /sys/fs/cgroup
/dev/sda1                      32768    351    32417    2% /boot
/dev/mapper/vg0-optvol        327680  19465   308215    6% /opt
/dev/mapper/vg0-homevol       131072    322   130750    1% /home
/dev/mapper/vg0-tmpvol        131072    166   130906    1% /tmp
/dev/mapper/vg0-varvol        327680   4486   323194    2% /var
/dev/mapper/vg0-logvol        131072    163   130909    1% /var/log
/dev/mapper/vg0-auditvol      327680     34   327646    1% /var/log/audit
/dev/mapper/vg1-optSPvol    32768000 156936 32611064    1% /opt/SP
/dev/mapper/vg0-varcrashvol  1048576     11  1048565    1% /var/crash
tmpfs                        4096453      1  4096452    1% /run/user/10603
[1;31mvg1108yr:resolve:[0m/opt/SP/resolve $ 

After my regex expression:

strRegex = “\d”

Result:

0
7
1
9
4
8
8
4
2
9
6
7
6
7
6
5
2
1
6
4
0
9
3
6
0
0
4
3
6
4

I would like to receive a result like this:

4093600    436  4093164   
 4096453      1  4096452    
 4096453   1384  4095069    
4096453     16  4096437    
 32768    351    32417    
 327680  19465   308215   
 131072    322   130750   
 131072    166   130906    
 327680   4486   323194    
 131072    163   130909    
 327680     34   327646    
 32768000 156936 32611064    
 1048576     11  1048565   
 4096453      1  4096452    

Any help is appreciated
Thank you

@Andre_Vieira

Try this: \d+\s+\d+\s+\d+\s or maybe you can group it like this: (\d+\s+)

1 Like

Hi @Andre_Vieira …Is this your expected output?

OR this…

1 Like

Hi @Andre_Vieira

Try this

(?<=\s+)\d+(?=\s+)

1 Like

Hi my dear, thank you for replying !!

719488 42967 676521
4093600 436 4093164
4096453 1 4096452
4096453 1384 4095069
4096453 16 4096437
1 32768 351
327680 19465 308215
131072 322 130750
131072 166 130906
327680 4486 323194
131072 163 130909
327680 34 327646
32768000 156936 32611064
1048576 11 1048565
4096453 1 4096452

This is almost there :smiley:
I will try to adjust the expression to see I can get a clean cut :smiley:

My dear friend!!

You never miss the target!

Big F Machine!!

2nd option worked for me.

Thank’s a lot for your time!!

1 Like

Hi Dear Nived!!

It was a close call!

Thank you for your time and effort :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.