Re: multi-line regular expression help
- From: Cesar Baquerizo <ces@xxxxxxxxxx>
- Date: Fri, 31 Mar 2006 19:47:17 GMT
Actually looking at both your answers made it clear what my problem was. I incorrectly assumed that multi-line match had an effect on the contents of $_.
As my data is on multiple lines and I was only reading in 1 line at a time, I could never match the regex over multiple lines.
Thanks
Tome wrote:
I copied and pasted your regex as well as your string and it worked with no problem:.
$string = "03/27 MON 07:59A [ 11:59A 12:44P] (b12:45P
b01:15P) 04:30P 8:00 0:00 0:00";
print "$&\n" if $string =~ /^\s*\d\d\/\d\d\s+[A-Z][A-Z][A-Z]\s+.*\d\:\d\d\s+\d\:\d\d\s*$/ms;
It definitely succeeded in the match and printed it fine. .* will match newlines as long as you
have /s.
Maybe if you post your code we can find the problem.
---Tome
On Fri, 31 Mar 2006 16:46:43 GMT, Cesar Baquerizo <ces@xxxxxxxxxx> 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)
^^
I was hoping that the above part (.*) would match a newline or anything else in this case and return it in $&.
Any help appreciated.
Thanks
- References:
- multi-line regular expression help
- From: Cesar Baquerizo
- Re: multi-line regular expression help
- From: Tome
- multi-line regular expression help
- Prev by Date: Re: Find duplicates in a dat file
- Next by Date: -e fails sometimes
- Previous by thread: Re: multi-line regular expression help
- Next by thread: filemaker pro and perl
- Index(es):
Relevant Pages
|