Regex Help!!

Hi All,

I need some regex help, I can never seem to get these right!!!

i'm pulling a line of code from a linux server and need to pull two strings from the line of code.

A same line of code is:

17:34pm  up 2 days 23:38,  1 user,  load average: 0.12, 0.06, 0.05

Can someone assist me with a regex that will pull just the uptime? So everything after 'up ' and before the first ', ' so that would equal: 2 days 23:38

I also need to pull the load average, but just the first number (in the sample, it would everything after 'load average: ' and before the ', ' after 0.12?

Thanks in advance, I have tried a heap of reg testers and just can't get it right!


up [0-9]+ days [0-9][0-9]:[0-9][0-9]

load average: 0.[0-9][0-9]

thanks nilton, load average worked fine, I ended up using a different command to pull the uptime from which got me around the number of days and it being two digits vs one.


You can "cat /proc/uptime". The first number is the number of seconds the system has been up and the second is the number of seconds the system has been idle (not too useful).