> I'd like to thank everybody who came up with suggestions.
> One thing I
> forgot to point out is that there are also people with
> whitespace in their
> *given* names, which seems to make things even more problematic
I've updated my solution to accommodate that:
while () {
my @cols =
At 04:43 PM 1/12/2006 -0500, Ted Schuerzinger wrote:
>$transfer[2] = scalar @line; # @line only has the names left
> for $x (0 .. 8) {
> print FILETO "$transfer[$x]\t";
> }
> print FILETO "\n"
>}
If @lines contains the name components then u need to do join " ", @lines to
get the contents
"Joe Discenza" <[EMAIL PROTECTED]> graced perl with these words
of wisdom:
> You seem to have a pretty good picture of your data; why not turn
> that into a regex completely, instead of doing it piecemeal?
>
> /(\d+)\s+\((\d+)\)\s+([A-Z\s]+),\s+([A-Z]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+
> ([A-Z]{3})\
<>Ted wrote:
<>while () {
chomp;
if ($_ =~/\d\s[A-Z]{3}\s/) {
$_ = s/$1/$1\t/g;
}
print FILETO "$_\n";
}
You were close Ted but there are a couple problems.
1. $_ = s/$1/$1\t/g; should be $_ =~ s/$1/$1\t/g; (you left out the ~)
2. $1 isn't defined anywhere in this code sinc
At 10:19 AM 1/12/2006,
=?koi8-r?Q?=E1=D2=D4=C5=CD=20=E1=D7=C5=D4=C9=D3=D1=CE?= wrote:
If you want tab instead of space after each country code, try this:
while () {
if (/\d\s[A-Z]{3}\s/) {
s/(\d\s[A-Z]{3})\s/$1\t/g;
}
print FILETO $_;
}
I don't see the point of the if statement. Why
> I'm fairly good at using regexes to find things, but using them to
> *replace* things is something I find quite difficult. I have
> a text file with lines like this:
>
>
>
> 1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
> 2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
> [...]
>
At 08:45 AM 1/12/2006 -0500, [EMAIL PROTECTED] wrote:
>1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
>2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
>[...]
>28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
>29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
>30 (35) KOUKALOV
Title: Yet another regex question
Ted Schuerzinger
wrote, on Thu 12-Jan-06 08:45: I have a text file with lines like
this::: 1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00: 2 (2)
CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00: [...]: 28 (28) MOLIK, ALICIA
671.00 15 .00 195.00 AUS .00:
If you want tab instead of space after each country code, try this:
while () {
if (/\d\s[A-Z]{3}\s/) {
s/(\d\s[A-Z]{3})\s/$1\t/g;
}
print FILETO $_;
}
>
> I'm fairly good at using regexes to find things, but using them to
> *replace* things is something I find quite difficult. I ha
> I'm trying to grab a website's description from the meta tags
> but I can't seem to make it work all the time.
As people have pointed out, it's best to use a parser to parse HTML, not a
regex. Here's some code (untested) as a starting point for two different
parsers.
# Sample HTML::Tokeparser
Don't use regular expressions to parse complex data like HTML. It's just not worth
it. Try HTML::TokeParser instead.
Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com
-Original Message-
From: Chris [mailto:[EMAIL PROTECTED]
Sent: T
11 matches
Mail list logo