Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regexp parses only first line correctly

by broomduster (Priest)
on Aug 16, 2008 at 19:10 UTC ( [id://704719]=note: print w/replies, xml ) Need Help??


in reply to Regexp parses only first line correctly

The 'partition' part of a line should be matched by
\/\w*
(no character class needed, and note '*' quantifier). Change the first line of your regex to
\s+ \w+: \s \/\w* \s+ # host, partition
and it will work (at least it does here).

Updated: added bit to note change in quantifier relative to OP.

Replies are listed 'Best First'.
Re^2: Regexp parses only first line correctly
by NetWallah (Canon) on Aug 16, 2008 at 19:22 UTC
    I had that initial suggestion as well, but withdrew that recommendation because it will fail if the line contains a path with more than one slash, such as :
    hostname: /dir3/dir4 level=incr, 1449 MB 00:56:31 46 + files
    Keeping the character class, but correcting repetition will work in this case as well.

         Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

      Yes, I see that you (almost completely) changed your original reply, but with no indication of the changes.

      Even better might be

      \s+ \w+: \s /\w*(?:/\w+)* \s+ # host, partition
      Update: Getting a regex in there that matches all possible (legal) path specifications is more complicated than what I have here. Usual advisories about "know your data" apply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://704719]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-03-28 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found