Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: regular expression problem

by binf-jw (Monk)
on Jun 12, 2009 at 12:51 UTC ( [id://770942]=note: print w/replies, xml ) Need Help??


in reply to regular expression problem

You have an extra space between .* and recvd, using \s it reads .*\s\srecvd. You should use \s for spaces to avoid subtle errors like this.
Also including /xms; is good as then you can add comments it forces you to use \s
my $line = "Fri May 29 18:29:57.357 2009 Morocco Standard Time INFO: pid 32 +16 tid 1724: 170: 132192: apricocot Native Server: recvd AA_BIN_MSG_V +ER_CHG"; my $MATCH_TIMESTAMP = qr{ \A ( .*? ) # Capture time-stamp \s INFO: .*? recvd \s AA_BIN_MSG_VER_CHG }xms; if ( $line =~ $MATCH_TIMESTAMP ) { # Made timestamp lexical, you might not want that. print my $timestamp = $1; }


J,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-24 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found