There are two regex modifiers that help. /s so that . matches \n and /m so that ^ and $ match at the start and end of logical lines. /x allows free formating and embedded comments.
Using these modifiers you regex can be written as
which will create an array withmy @array = $line =~ m{ ^(LENGTH: # a line beginning with LENGTH: .*?) # as little as possible until ^(SUBJECT: # a line beginning with SUBJECT: .*?) # as little as possible until ^(COMMENT: # a line beggining with COMMENT .*) # and the rest }msx
$VAR1 = [ 'LENGTH: ................................................... +... .................................................................. .................................................................. ................................................................... .................................................................. ', 'SUBJECT: .................................................. +..... ', 'COMMENT: .................................................. +... .................................................................... ' ];
In reply to Re: I need to regex multiple lines
by hipowls
in thread I need to regex multiple lines
by legend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |