in reply to Re: regular expression ignores two lines
in thread regular expression ignores two lines
#!/usr/bin/perl use strict; use warnings; my $tag; while (<DATA>) { s/\s*<\s*(\/?)\s*(\w+)\s*>\s*/$1?"\n\n":"\n\n\{$2\}\n\n"/ge; chomp; s/[\cA-\cZ]//g; # To remove control characters #print "Again printing the \$_ : $_\n"; s/^[\\|<]$//g; # To delete the character like \ and < at the e +nd of the line s/[\\|<]$//; # To delete the character like \ and < at the beg +ining of the line s/^\s+//g; # To remove multiple spaces at the begining of the + line s/\s+$//g; # To remove spaces at the end of the line if (/^\{(.*)\}$/) { $tag = $1; print "The tag is $tag\n"; } } __DATA__ {SOURCETAG} 0904230634 {DATE} 090424 {EDITION} 1 {HEADLINE} heredero del famoso deportista mexicano, lucha por enaltecer la vida y + obra del autor de sus dM-mas {SOURCE} Por Gisela Orozco 312.527.8461/ Chicago\ <LINE> Por Gisela Orozco< TTL +>312.527.8461/ Chicago</TTL>
The tag is SOURCETAG The tag is DATE The tag is EDITION The tag is HEADLINE The tag is SOURCE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regular expression ignores two lines
by Crackers2 (Parson) on Aug 20, 2009 at 12:48 UTC | |
|
Re^3: regular expression ignores two lines
by Bloodnok (Vicar) on Aug 20, 2009 at 09:36 UTC | |
|
Re^3: regular expression ignores two lines
by ashish.kvarma (Monk) on Aug 20, 2009 at 12:53 UTC | |
|
Re^3: regular expression ignores two lines
by Anonymous Monk on Aug 20, 2009 at 09:27 UTC |