Re: multi-line regular expression help
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 31 Mar 2006 10:48:49 -0800
Cesar Baquerizo wrote:
Hello,
I am having a problem trying to match both of the following strings:
03/23 THU 07:09A (b12:00P b12:30P) 04:30P 8:00 0:00 0:00
as well as (embedded newline):
03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
b01:15P) 04:30P 8:00 0:00 0:00
The first string always matches, but the second never matches. I've
tried different incarnations of the following regex with no success:
(/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms)
^^
Odd, they both match just fine for me:
#!/usr/bin/perl
use strict;
use warnings;
#any newline in string below is the result of newsreader-wrapping
$_ = '03/23 THU 07:09A (b12:00P b12:30P) 04:30P 8:00 0:00
0:00';
if (/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms) {
print "First matched\n";
}
#newline in below string after '12:45P'
$_ = '03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
b01:15P) 04:30P 8:00 0:00 0:00';
if (/^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms) {
print "Second matched\n";
}
__END__
First matched
Second matched
Perhaps you could post a short-but-complete script (as recommended by
the Posting Guidelines - have you read them yet?) which demonstrates
your error?
Paul Lalli
.
- References:
- multi-line regular expression help
- From: Cesar Baquerizo
- multi-line regular expression help
- Prev by Date: Re: changing .cpan location
- Next by Date: substition in perl
- Previous by thread: multi-line regular expression help
- Next by thread: Re: multi-line regular expression help
- Index(es):
Relevant Pages
|