crusty_collins has asked for the wisdom of the Perl Monks concerning the following question:
I have a regex problem that i cant figure out.
I need to get the following paragraph out of a file.
First i get that account number then i get the paragraph.
Question : How do i get the full paragraph skipping the cr and lf (\r\n)? Code
Outputuse strict; use warnings; use Data::Dumper; my $self = {}; while (my $line = <DATA>) { if( $line =~ /ACCOUNT\s+NUMBER\s+(\d+)/ ){ $self->{ACCOUNTNUMBER} = $1; print "$1 \n"; }elsif ($line =~ /^(YOUR[\s\w]+)(\d+\.\d+)(.*)/sm ){ print "$1 $2 $3 \n"; } } __DATA__ ACCOUNT NUMBER 000111111111 YOUR LOAN PAYMENT FOR THE YEAR WILL BE 00.00 OF WHICH 00.00 WILL BE FOR PRINCIPAL AND INTEREST, 00.00 WILL GO ESCROW ACCOUNT, AND .00 WILL BE FOR DISCRETIONARY ITEMS THAT YOU CHOSE TO BE INCLUDED WITH YOUR LOAN PAYMENT. THE EFFECTIVE DATE OF YOUR NEW SCHEDULED PAYMENT IS 00/00/00.
000111111111 YOUR LOAN PAYMENT FOR THE COMING YEAR WILL BE 0 0.00
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex : get a paragraph, not just line
by AnomalousMonk (Archbishop) on Mar 18, 2015 at 18:44 UTC | |
Re: regex : get a paragraph, not just line
by jeffa (Bishop) on Mar 18, 2015 at 18:45 UTC | |
Re: regex : get a paragraph, not just line
by sauoq (Abbot) on Mar 18, 2015 at 19:50 UTC | |
Re: regex : get a paragraph, not just line
by atcroft (Abbot) on Mar 18, 2015 at 18:07 UTC | |
Re: regex : get a paragraph, not just line
by hdb (Monsignor) on Mar 18, 2015 at 20:21 UTC | |
by sauoq (Abbot) on Mar 18, 2015 at 21:55 UTC | |
Re: regex : get a paragraph, not just line
by crusty_collins (Friar) on Mar 19, 2015 at 13:54 UTC |