> 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})\
True. Wanted to be the first replier ;)
Artem A. Avetisyan
>
> 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})\
<>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
Probably not the best but a working solution is to split the string using
"split", find out wether there are to much fields, consider they are
two-or-more-word names, join the corresponding name-fields with a space and the
overall with tabs.
Dietmar
--- snip ---
I'm fairly good at using re
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 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
[...]
28 (28) MOLIK, ALICI
Joseph Discenza graced perl with these words of wisdom:
> I haven't seen anyone recommend this: /T.*T/i to match two 'T's. I'm not
> going to compare this to $Bill's word-matching routine :).
That's such a simple solution, and it seems to work. In a previous post,
I wrote:
> As an example, sup
Ted Schuerzinger wrote, on Saturday, November 06, 2004 3:29 PM
: I'm an avid, but not very good, Scrabble player. Last night, I was
: playing, and suffered a major brain cramp when I got a rack
: of four vowels
: *and* two blanks: AEIUR**. I couldn't come up with anything
: at the time
$Bill Luebkert graced perl with these words of wisdom:
> Outer:
Hmm I don't understand what the lines "Outer:" and "next Outer;" do.
> while () {
> if (/^[a-z]{7}$/i) {
>
> my $word = $_;
> foreach (qw(a e r s t t t)) {
>if (not $word =~ s/$_//i) {
Glenn Linderman graced perl with these words of wisdom:
> Maybe Ted doesn't care about the performance of repeated similar
> queries. Depends on if he's "cheating in real time", or just
> occasionally wants to check a word. But he did mention the word
> "efficient" in the original posting.
N
Glenn Linderman wrote:
> It looks like you're assuming the 8th letter must be at the beginning or
> end of the 7 letters on the rack. However, depending on the open space
> on the board, the 8th letter (already on the board) could really be
> placed at any position in the resulting 8 letter wo
Glenn Linderman wrote:
> On approximately 11/6/2004 8:48 PM, came the following characters from
> the keyboard of $Bill Luebkert:
>
>>Glenn Linderman wrote:
>>
>>
>>
>>>Let's say you had AERSTTT in your rack (yep, that's the thing that
>>>holds the tiles). Now, clearly that matches the wor
Ted Schuerzinger wrote:
> $Bill Luebkert graced perl with these words of wisdom:
>
>
>>Ted Schuerzinger wrote:
>>
>>
>>>I'm an avid, but not very good, Scrabble player. Last night, I was
>>>playing, and suffered a major brain cramp when I got a rack of four
>>>vowels *and* two blanks: AEIUR*
Glenn Linderman wrote:
> Let's say you had AERSTTT in your rack (yep, that's the thing that
> holds the tiles). Now, clearly that matches the word "tatters". But
> how would you make the regex that finds it, but doesn't find "batters",
> "matters", "hatters", "patters", and even "praters"
$Bill Luebkert graced perl with these words of wisdom:
> Ted Schuerzinger wrote:
>
>> I'm an avid, but not very good, Scrabble player. Last night, I was
>> playing, and suffered a major brain cramp when I got a rack of four
>> vowels *and* two blanks: AEIUR**. I couldn't come up with anythin
Ted Schuerzinger wrote:
> I'm an avid, but not very good, Scrabble player. Last night, I was
> playing, and suffered a major brain cramp when I got a rack of four vowels
> *and* two blanks: AEIUR**. I couldn't come up with anything at the time,
> so this morning wrote a simple Perl script
I'm an avid, but not very good, Scrabble player. Last night, I was
playing, and suffered a major brain cramp when I got a rack of four vowels
*and* two blanks: AEIUR**. I couldn't come up with anything at the time,
so this morning wrote a simple Perl script using a regex:
if ($_ =~/\b[a-z]
> "bruce" <[EMAIL PROTECTED]>
> > $foo = "foo.txt"
> >
> > i simply want to separate on the "."
>
> Try:
>
> use File::Basename;
> #
> my $foo = "foo.txt";
> my $ans = fileparse($foo, ('.txt'));
> print "$ans\n";
>
If you REALLY want to use the regex, you could try one of the following:
--
"bruce" <[EMAIL PROTECTED]>
hi..
a simple/basic/embarassingly simple one...
i have:
$foo = "foo.txt"
i simply want to separate on the "."
ie
$foo =~ /([^.]+).txt/
$ans = $1
this doesn't seem to get $ans = 'foo'
Try:
use File::Basename;
#
my $foo = "foo.txt";
my $ans = fileparse($foo, ('.txt'));
A further debug/syntax nitpick:
print "foo='$foo'\n";
$foo =~ /([^.]+).txt/;
$ans = $1;
print "ans='$ans'\n";
best as:
my ($foo, $ans);
print "foo='$foo'\n";
if ( $foo =~ /([^.]+)\.txt/ ) {
$ans = $1;
} else {
$ans="match failed on: $foo";
}
print "ans='$ans'\n";
if you ch
'ppreciate the responses!!
it was a typo! f^*&ng fingers!!
-bruce
-Original Message-
From: Gardner, Sam [mailto:[EMAIL PROTECTED]
Sent: Friday, October 15, 2004 10:54 AM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: simple regex question
Well, just as a
bruce wrote, on Friday, October 15, 2004 1:39 PM
: a simple/basic/embarassingly simple one...
:
: i have:
:
: $foo = "foo.txt"
:
: i simply want to separate on the "."
:
: ie
: $foo =~ /([^.]+).txt/
: $ans = $1
:
: this doesn't seem to get $ans = 'foo'
Maybe you're going for s
Hi Bruce
I would use split(/\./,$foo) Mike
- Original Message -
From: "bruce" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: October 15, 2004 1:38 PM
Subject: simple regex question
> hi..
>
> a simple/basic/embarassingly simple one...
&g
Title: RE: simple regex question
Well, just as a basic note, you are aware that the "." in regexes matches ANY character (except a newline, in most situations), right? But also, you seem to have put ^. Inside a character class, so it won't be "beginning of the string, an
Hi Bruce--
You're getting confused by the multiple regexp uses of ".". When it
is in a character class or escaped: "[.]" or "\.", it means a literal
period, when it's unescaped: "." it means "any character." You've got
them backwards in your regexp. Try:
perl -le '$foo = qq/foo.txt/; $foo =~ /
tpick, but you did not include the
semicolons which end your statements. So clearly
this is not a pure cut/paste from your code.
--
Mike Arms
-Original Message-
From: bruce [bedouglas AT earthlink DOT net]
Sent: Friday, October 15, 2004 11:39 AM
To: [EMAIL PROTECTED]
Subject: simple regex
hi..
a simple/basic/embarassingly simple one...
i have:
$foo = "foo.txt"
i simply want to separate on the "."
ie
$foo =~ /([^.]+).txt/
$ans = $1
this doesn't seem to get $ans = 'foo'
any ideas as to what i've screwed up...
thanks
bruce
___
Pe
-Original Message-
> So I'm trying to think like a regular expression (a new concept there...),
so I try to find things in common:
>
> 1) They all start with http:// :) (not much help there)
> 2) They all end with a '\/.+\/.+\.?' (could this be the key?) (Is #2
the right regex for sla
In my prior post, I should have added:
> The point of retrieving this data is to hit each link
> (returning the HTTP code), scan it for HTML tags,
> and then check the functionality of the links.
You may want to look into the WWW::Link suite of modules before you try to
reinvent them:
http://
Jeremy Junginger graced perl with these words of wisdom:
> I'm extracting links from an html page (using the HTML tags).
> Woohoo! I'm not having any problems with that part. The data looks
> that's getting returned is (much to my surprise) formatted exactly
> like I wanted itagain Woohoo!
The answer to your HTML-parsing-with-a-regex question is: don't do it.
Parsing HTML should be done with an HTML parser. This is hinted at in
PerlFaq6 and PerlFaq9, but it's not as explicit as it should be.
I would recommend HTML::TokeParser or HTML::LinkExtor for your needs.
--
M
I have a cool regex question for you guys. (Still reading O'Reilly's
"Mastering Regular Expressions"...and my head's still spinning...)
I'm extracting links from an html page (using the HTML tags). Woohoo!
I'm not having any problems with that part. The da
> 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
Yes, good advice: We are using HTML::Parser, which seems to be just another interface.
Got all information of a page I ever wanted (and much more ;-)
Dietmar
> -Ursprüngliche Nachricht-
> Von: Peter Guzis [mailto:[EMAIL PROTECTED]
> Betreff: RE: Yet another regex question
&
CTED]
Sent: Tuesday, March 23, 2004 2:58 PM
To: perl-win32-users
Subject: Yet another regex question
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. In some websites, the tag is closed with
a ">, and in others
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. In some websites, the tag is closed with
a ">, and in others, the tag is closed using " /> or "/>. Is there a way to
do this with regex?
$foo = qq~~;
($good) = ($foo=~ m#ption" content="\s
Thomas, Mark - BLS CTR graced perl with these words of wisdom:
> For the letter-substitution matches, why not create mini-re for each
> one?
>
> $a = qr/[EMAIL PROTECTED]/;
> $i = qr/[i1l\|]/;
>
> $str = "v|agr@";
>
> if ($str =~ /v${i}${a}gr${a}/) {
> #it's spam
> }
>
Because Hamster d
Mark Thomas wrote:
>
> > (i|1|l|\|) to kill the vertical pipe, but I find that much
> > harder to read and more difficult to extend later on.
>
> For the letter-substitution matches, why not create mini-re for each one?
>
> $a = qr/[EMAIL PROTECTED]/;
> $i = qr/[i1l\|]/;
>
> $str = "v|agr@";
>
> (i|1|l|\|) to kill the vertical pipe, but I find that much
> harder to read and more difficult to extend later on.
For the letter-substitution matches, why not create mini-re for each one?
$a = qr/[EMAIL PROTECTED]/;
$i = qr/[i1l\|]/;
$str = "v|agr@";
if ($str =~ /v${i}${a}gr${a}/) {
Andy,
I got
it working but without \b ( just plain and simple as Lynn and Jingmei said
).
I
should have figured out by myself ;-(.
Thanks,
Nicu
-Ursprüngliche Nachricht-Von:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]Gesendet: Montag, 20. Oktober
2003 17:15An: [EMAI
You can use matching like this ...
if ($stringToSplit =~ /Cat/) {
print "found the string\n";
}
[EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
10/20/2003 09:49 AM
To: [EMAIL PROTECTED]
cc:
Subject: Regex ques
Title: Regex question.
Hi *,
I have a problem with a regex. I want to be able to detect if in some word I will find a subword , for example
if "cat" is in "Pisiccat" . I have one ideea and that is to split the PisiCcat after cat and then to check if the first variab
On Thu, 6 Feb 2003, Richard Morse wrote:
> On 02/06/2003 2:09 PM, "Ben Gonzalez" <[EMAIL PROTECTED]> wrote:
>
> > All,
> >
> > I have a string that can contain any number from 0 to 1048575.
> >
> > I can verify that the numbers are digits like this: ^\d{1,7}$
> >
> > The above regex matches any 1
On Thu, 6 Feb 2003, Ben Gonzalez wrote:
> All,
>
> I have a string that can contain any number from 0 to 1048575.
>
> I can verify that the numbers are digits like this: ^\d{1,7}$
>
> The above regex matches any 1 to 7 digits. It will ensure that the string
> contains digits 0 to 999.
>
> I ne
Lee Goddard wrote:
>
> > Lee Goddard wrote:
> > >
> > > > > I need to split a string at all full-stops '.'
> > > > > unless they are part of a sub-string within quotes.
> > > > >
> > > > > Should I manually loop over the file, setting flags,
> > > > > or can I do this with a regular expression?
>
> Lee Goddard wrote:
> >
> > > > I need to split a string at all full-stops '.'
> > > > unless they are part of a sub-string within quotes.
> > > >
> > > > Should I manually loop over the file, setting flags,
> > > > or can I do this with a regular expression?
> > >
> > > And of course, I need to
Lee Goddard wrote:
>
> > > I need to split a string at all full-stops '.'
> > > unless they are part of a sub-string within quotes.
> > >
> > > Should I manually loop over the file, setting flags,
> > > or can I do this with a regular expression?
> >
> > And of course, I need to have escaped sing
> > I need to split a string at all full-stops '.'
> > unless they are part of a sub-string within quotes.
> >
> > Should I manually loop over the file, setting flags,
> > or can I do this with a regular expression?
>
> And of course, I need to have escaped single-quotes too,
> \'
In other wor
> I need to split a string at all full-stops '.'
> unless they are part of a sub-string within quotes.
>
> Should I manually loop over the file, setting flags,
> or can I do this with a regular expression?
And of course, I need to have escaped single-quotes too,
\'
Thanks in anticipation...
l
> -Original Message-
> From: Lee Goddard [mailto:[EMAIL PROTECTED]]
> Sent: 07 June 2001 11:14
> To: Perl_Users
> Subject: Regex Question: splitting at a point unless part of a quoted
> substring
> I need to split a string at all full-stops '.'
> un
I need to split a string at all full-stops '.'
unless they are part of a sub-string within quotes.
Should I manually loop over the file, setting flags,
or can I do this with a regular expression?
Thanks in anticipation,
lee
___
Perl-Win32-Users mail
"[EMAIL PROTECTED]" wrote:
>
> Hi, how can I rewrite this so it's more efficient? Thanks!!!
>
> -Tha
>
> $s = "13:01:13 HTTP request from FiskNT for
> www.bostonphoenix.com/portal/boston/monday.html; result = 200 OK";
>
> $s =~ m/(\d\d:\d\d).*from (\w+) for (.*\.[a-zA-z]+)\/(.*);/;
> $time = $
-start-
> "[EMAIL PROTECTED]" at05/03/2001 12:44 PM
>Hi, how can I rewrite this so it's more efficient? Thanks!!!
If every log entry is the *same* format...
>$s = "13:01:13 HTTP request from FiskNT for
>www.bostonphoenix.com/portal/boston/monday.html; result = 200 OK";
>$s =~ m/(\d\d:\d
On Thu, 3 May 2001, [EMAIL PROTECTED] wrote:
> Hi, how can I rewrite this so it's more efficient? Thanks!!!
>
>
> $s = "13:01:13 HTTP request from FiskNT for
> www.bostonphoenix.com/portal/boston/monday.html; result = 200 OK";
>
> $s =~ m/(\d\d:\d\d).*from (\w+) for (.*\.[a-zA-z]+)\/(.*);/;
> $ti
($time,$user,$rooturl,$suburl) =~ m/(\d{2}:\d{2}).*from (\w+) for
(.*\.[a-zA-z]+)\/(.*);/;
not a lot better...
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 03, 2001 1:44 PM
To: [EMAIL PROTECTED]
Subject: Regex Question
Hi, how can I
Hi, how can I rewrite this so it's more efficient? Thanks!!!
-Tha
$s = "13:01:13 HTTP request from FiskNT for
www.bostonphoenix.com/portal/boston/monday.html; result = 200 OK";
$s =~ m/(\d\d:\d\d).*from (\w+) for (.*\.[a-zA-z]+)\/(.*);/;
$time = $1;
$user = $2;
$rooturl= $3;
$suburl = $4;
_
>I would like a regex to replace leading zeroes in a number. For example, a
>ten-digit number string has 5 leading (leftmost) zeroes. I would like to
>replace each leading zero with a space, i.e. 5 leading zeroes with 5
leading
>spaces. I tried s/^0+/ /g but it replaced all leading zeroes with on
>I would like a regex to replace leading zeroes in a number. For example, a
>ten-digit number string has 5 leading (leftmost) zeroes. I would like to
>replace each leading zero with a space, i.e. 5 leading zeroes with 5
leading
>spaces. I tried s/^0+/ /g but it replaced all leading zeroes with on
I would like a regex to replace leading zeroes in a number. For example, a
ten-digit number string has 5 leading (leftmost) zeroes. I would like to
replace each leading zero with a space, i.e. 5 leading zeroes with 5 leading
spaces. I tried s/^0+/ /g but it replaced all leading zeroes with only on
65 matches
Mail list logo