How the hell do I represent that as a regular expression. I have only dabbled in regular expressions once before, and this is out of my league.
So far I can only tell that its formatted correctly using:
gotta use the double back slashes to stop gcc bitching about "unknown escape sequence". The only thing left to do is make it so apps that are enclosed in brackets([]) are read too.
Last edited by M_D_K on Mon Jan 26, 2009 3:04 pm, edited 1 time in total.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote:
<sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
M_D_K wrote:OK I really hope someone knows regular expressions. I need to read the output of ps(linux program), and extract the fields. The output looks like this
I'm not sure, but what about
^\s*(\d)+\s+(\w)+\s+(^\s)*\s*$
Start of line, zero or more whitespace characters, one or more digits (PID), one or more whitespace, one word (USER), one or more whitespace, zero or more of everything that's not whitespace (APP), zero or more whitespace to end of string? That's what I intended anyway.
"\s" is whitespace so it includes a tab, too. But if it's really spaces then \s+, I think, right?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
didn't put $ at the end cause I only wanted the app name and not all the crap that got passed to it. Oh BTW \w wouldn't work i'm not using advance regex just extended hence the second backreference.
And yeah \s+ is one or more whitespaces.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote:
<sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
^\s for app name won't work for you? ... duh yeah, of course it won't, they can have spaces. So I would say first alphanumeric char and everything after that to newline or end?
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
the extracted tuff then gets put into a list control. Also You'll be hard pressed to find a linux app with spaces in its name. There is a long standing tradition of using underscores in place of spaces.
"//that \\s is the whitespace double slash because well I allready said in my first post."
Yeah I know. Did I forget to change it? Sorry, my bad.
Confused about what? Is the problem that it's not grabbing everything? Looks like we just need another \\s+(whatever) ? I only had three because I missed the single space between appname and path.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
MarauderIIC wrote:^\s for app name won't work for you? ... duh yeah, of course it won't, they can have spaces. So I would say first alphanumeric char and everything after that to newline or end?
Thats what confused me.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote:
<sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
MarauderIIC wrote:So I would say first alphanumeric char and everything after that to newline or end?
Thats what confused me.
First alphanumeric char is [A-Za-z0-9], or whatever, add all the chars that can possibly be the first character in a filename.
([A-Za-z0-9]+.*)
All characters after that is .*
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.