Re: regex help - only one value returned

2020-12-02 Thread Jim Gibson
In your original example: print "match1='$1' '$2'\n" if ($T=~/^((mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi); print "match2='$1' '$2'\n" if ($T=~/^(mr|mrs|miss|dr|prof|sir .{5,}?)\n/smi); the interior parentheses in example one terminates the alternation, so the last string is ’sir’. In example

Re: regex help - only one value returned

2020-12-02 Thread Gary Stainburn
On 02/12/2020 13:56, Vlado Keselj wrote: Well, it seems that the first one is what you want, but you just need to use $1 and ignore $2. You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not want for them to be captured in $2, you can use: '(?:mr|mrs|miss|dr|prof|sir)'. For

Re: regex help - only one value returned

2020-12-02 Thread Vlado Keselj
Well, it seems that the first one is what you want, but you just need to use $1 and ignore $2. You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not want for them to be captured in $2, you can use: '(?:mr|mrs|miss|dr|prof|sir)'. For example: print "match3='$1' '$2'\n" if

regex help - only one value returned

2020-12-02 Thread Gary Stainburn
I have an array of regex expressions that I apply to text returned from tesseract. Each match that I get then gets stored for future processing. However, I'm struggling with one regex. The problem is that: 1) with brackets round the titles it returns two matches. 2) without brackets, it

Re: Regex help needed

2013-01-09 Thread *Shaji Kalidasan*
gift back to God. --- From: punit jain contactpunitj...@gmail.com To: beginners@perl.org beginners@perl.org Sent: Tuesday, 8 January 2013 5:58 PM Subject: Regex help needed Hi , I have

Re: Regex help needed

2013-01-09 Thread Dr.Ruud
On 2013-01-08 13:28, punit jain wrote: { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1 = (passfile,pasfile1,user); } and so on The requirement is to have the file parsing so that final output is :- test =

Regex help needed

2013-01-08 Thread punit jain
Hi , I have a file as below : - { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1 = (passfile,pasfile1,user); } and so on The requirement is to have the file parsing so that final output is :- test =

Re: Regex help needed

2013-01-08 Thread Jim Gibson
On Jan 8, 2013, at 4:28 AM, punit jain wrote: Hi , I have a file as below : - { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1 = (passfile,pasfile1,user); } and so on The requirement is to

Re: Regex help needed

2013-01-08 Thread timothy adigun
Hi punit jain, Please check my comments below. On Tue, Jan 8, 2013 at 1:28 PM, punit jain contactpunitj...@gmail.comwrote: Hi , I have a file as below : - { test = (test123); test = (test123,abc); test = (test123,abc,xyz); } { test1 = (passfile); test1 = (passfile,pasfile1); test1

Regex help

2012-12-22 Thread punit jain
Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From (S___-0003) Tue Nov 16 03:10:15 2010 content-class: urn:content-classes:person Date: Tue, 16 Nov 2010 11:10:15 +0800 Subject: test

Re: Regex help

2012-12-22 Thread Paul Johnson
On Sat, Dec 22, 2012 at 04:45:21PM +0530, punit jain wrote: Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From (S___-0003) Tue Nov 16 03:10:15 2010 content-class:

Re: Regex help

2012-12-22 Thread David Precious
On Sat, 22 Dec 2012 16:45:21 +0530 punit jain contactpunitj...@gmail.com wrote: Hi, I have a file like below : - [snipped example - vcards with mail headers etc in between] My requirement is to get all text between BEGIN:VCARD and END:VCARD and all the instances. So o/p should be :-

Re: Regex help

2012-12-22 Thread Rob Dixon
On 22/12/2012 11:15, punit jain wrote: Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From (S___-0003) Tue Nov 16 03:10:15 2010 content-class: urn:content-classes:person Date: Tue, 16 Nov

Re: regex help

2011-10-28 Thread Chris Stinemetz
On Wed, Oct 19, 2011 at 1:10 AM, Leo Susanto leosusa...@gmail.com wrote: use strict; my %CELL; my %CELL_TYPE_COUNT; my $timestamp; my $hour; while (my $line = DATA) { if ($line =~ m|\d{1,2}/\d{1,2}/\d{2} ((\d{1,2}):\d{1,2}:\d{1,2})|) { #10/17/11 18:25:20 #578030

Re: regex help

2011-10-28 Thread Jim Gibson
On 10/28/11 Fri Oct 28, 2011 2:15 PM, Chris Stinemetz chrisstinem...@gmail.com scribbled: On Wed, Oct 19, 2011 at 1:10 AM, Leo Susanto leosusa...@gmail.com wrote: use strict; my %CELL; my %CELL_TYPE_COUNT; my $timestamp; my $hour; while (my $line = DATA) { if ($line =~

Re: regex help

2011-10-19 Thread Leo Susanto
use strict; my %CELL; my %CELL_TYPE_COUNT; my $timestamp; my $hour; while (my $line = DATA) { if ($line =~ m|\d{1,2}/\d{1,2}/\d{2} ((\d{1,2}):\d{1,2}:\d{1,2})|) { #10/17/11 18:25:20 #578030 $timestamp = $1; $hour = $2; } if ($line =~

Re: regex help

2011-10-18 Thread John W. Krahn
Brian Fraser wrote: On Tue, Oct 18, 2011 at 12:32 AM, Chris Stinemetz chrisstinem...@gmail.comwrote: /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/ Spot the issue: / 17#Or | 18#Or | 19#Or | 20#Or |

Re: regex help

2011-10-18 Thread John W. Krahn
Chris Stinemetz wrote: Hello, Hello, [*SNIP*] #!/usr/bin/perl use warnings; use strict; use POSIX; # my $filepath = sprintf(/omp/omp-data/logs/OMPROP1/%s.APX,strftime(%y%m%d%H,localtime)); my $filepath = (/tmp/110923.APX); # for testing my $runTime =

Re: regex help

2011-10-18 Thread Chris Stinemetz
On Mon, Oct 17, 2011 at 10:57 PM, Leo Susanto leosusa...@gmail.com wrote: From looking at the regex  if ($line =~ /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){ against the data 10/17/11 18:25:20 #578030  25 REPT:CELL 221 CDM 2, CRC, HEH     SUPPRESSED MSGS: 0    

Re: regex help

2011-10-18 Thread Igor Dovgiy
Maybe this'll be helpful. ) my $time_rx = qr/(?timestamp (?hour \d{2} ) (?: :\d{2} ){2} ) /x; my $cell_record_rx = qr/CELL \s+ (?cell_number \d+) \s+

regex help

2011-10-17 Thread Chris Stinemetz
Hello, I am getting the following error when I am trying to use regex to match a pattern and then access the memory variables: Any insight as to what I am doing wrong is greatly appreciated. Thank you, Chris Use of uninitialized value $1 in hash element at ./heh.pl line 22, $fh line 1211. Use

Re: regex help

2011-10-17 Thread Leo Susanto
From looking at the regex  if ($line =~ /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){ against the data 10/17/11 18:25:20 #578030  25 REPT:CELL 221 CDM 2, CRC, HEH     SUPPRESSED MSGS: 0     ERROR TYPE: ONEBTS MODULAR CELL ERROR     SET: MLG BANDWIDTH CHANGE     MLG

Re: regex help

2011-10-17 Thread Brian Fraser
On Tue, Oct 18, 2011 at 12:32 AM, Chris Stinemetz chrisstinem...@gmail.comwrote: /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/ Spot the issue: / 17#Or | 18#Or | 19#Or | 20#Or | 21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH /x For anything

regex help

2011-10-10 Thread Chris Stinemetz
Any help is appreciated. Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? For example in this case I would like the print results to be: **01 REPT:CELL 983 CDM 1, CCU 1, CE 5, HEHTimestamp: 10/10/11 00:01:18

Re: regex help

2011-10-10 Thread Brian Fraser
On Mon, Oct 10, 2011 at 4:56 PM, Chris Stinemetz chrisstinem...@gmail.comwrote: Any help is appreciated. Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? For example in this case I would like the print results to be:

Re: regex help

2011-10-10 Thread Chris Charley
Chris Stinemetz wrote in message Any help is appreciated. Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? For example in this case I would like the print results to be: **01 REPT:CELL 983 CDM 1, CCU 1, CE 5, HEH

Re: regex help

2011-10-10 Thread John W. Krahn
Chris Stinemetz wrote: Any help is appreciated. It looks like you don't need regex help. Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? For example in this case I would like the print results to be: **01 REPT:CELL 983

Re: regex help

2011-10-10 Thread Shawn H Corey
On 11-10-10 03:56 PM, Chris Stinemetz wrote: Any help is appreciated. Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? For example in this case I would like the print results to be: **01 REPT:CELL 983 CDM 1, CCU 1, CE 5, HEH

Re: regex help

2011-10-10 Thread John Delacour
At 14:56 -0500 10/10/11, Chris Stinemetz wrote: Once I match HEH how can alter the program to print the contents that are in the two lines directly above the match? If it's only one instance you need to deal with then this should do the trick: #!/usr/bin/perl use strict; my @lines; while

Re: Regex help

2011-05-17 Thread Rob Dixon
On 16/05/2011 23:44, Owen wrote: I am trying to get all the 6 letter names in the second field in DATA below, eg BARTON DARWIN DARWIN But the script below gives me all 6 letter and more entries. What I read says {6} means exactly 6. What is the correct RE? I have solved the problem my

Regex help

2011-05-16 Thread Owen
I am trying to get all the 6 letter names in the second field in DATA below, eg BARTON DARWIN DARWIN But the script below gives me all 6 letter and more entries. What I read says {6} means exactly 6. What is the correct RE? I have solved the problem my using if (length($data[1]) == 6 ) but

Re: Regex help

2011-05-16 Thread Jim Gibson
On 5/16/11 Mon May 16, 2011 3:44 PM, Owen rc...@pcug.org.au scribbled: I am trying to get all the 6 letter names in the second field in DATA below, eg BARTON DARWIN DARWIN But the script below gives me all 6 letter and more entries. What I read says {6} means exactly 6. \S{6} will

Re: Need a Perl Regex Help

2009-11-14 Thread Parag Kalra
Thanks 007 It worked out of the box :) Cheers, Parag On Fri, Nov 13, 2009 at 8:03 PM, 7 7stud.7s...@gmail.com wrote: On Fri, Nov 13, 2009 at 5:07 AM, Parag Kalra paragka...@gmail.com wrote: Hey All, I have a following a LDIF file to process through Perl -

Need a Perl Regex Help

2009-11-13 Thread Parag Kalra
Hey All, I have a following a LDIF file to process through Perl - ### dn: ou=71404558, ou=Company, ou=Personal, o=paragkalra.com dn: ou=People, ou=71404558, ou=Company, ou=Personal, o=paragkalra.com dn: ou=Groups, ou=71404558,

Re: Need a Perl Regex Help

2009-11-13 Thread 7
On Fri, Nov 13, 2009 at 5:07 AM, Parag Kalra paragka...@gmail.com wrote: Hey All, I have a following a LDIF file to process through Perl - ### dn: ou=71404558, ou=Company, ou=Personal, o=paragkalra.com dn: ou=People, ou=71404558,

Re: Need a Perl Regex Help

2009-11-13 Thread 7
On Fri, Nov 13, 2009 at 5:07 AM, Parag Kalra paragka...@gmail.com wrote: Hey All, I have a following a LDIF file to process through Perl - ### dn: ou=71404558, ou=Company, ou=Personal, o=paragkalra.com dn: ou=People, ou=71404558,

Re: Need a Perl Regex Help

2009-11-13 Thread Shawn H Corey
Parag Kalra wrote: I have a following a LDIF file to process through Perl - Any pointers? http://search.cpan.org/search?query=LDIFmode=all -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl;

RegEx help please ...

2008-08-11 Thread Saya
Hi, I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/ web-media/images/bday-after-help.jpg,javascript:popUp('/pop-ups/ birthday/main.html','bday-pics',785,460); Now I want $s to be like: /metadata-files/test-desc.txt,/metadata-

Re: RegEx help please ...

2008-08-11 Thread Mr. Shawn H. Corey
On Mon, 2008-08-11 at 14:02 -0700, Saya wrote: Hi, I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/ web-media/images/bday-after-help.jpg,javascript:popUp('/pop-ups/ birthday/main.html','bday-pics',785,460); Now I want $s to be like:

Re: RegEx help please ...

2008-08-11 Thread Rob Dixon
Saya wrote: I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/ web-media/images/bday-after-help.jpg,javascript:popUp('/pop-ups/ birthday/main.html','bday-pics',785,460); Now I want $s to be like: /metadata-files/test-desc.txt,/metadata-

Re: RegEx help please ...

2008-08-11 Thread Rob Dixon
Mr. Shawn H. Corey wrote: On Mon, 2008-08-11 at 14:02 -0700, Saya wrote: I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/ web-media/images/bday-after-help.jpg,javascript:popUp('/pop-ups/ birthday/main.html','bday-pics',785,460); Now I want

Re: RegEx help please ...

2008-08-11 Thread Mr. Shawn H. Corey
On Mon, 2008-08-11 at 23:30 +0100, Rob Dixon wrote: Mr. Shawn H. Corey wrote: On Mon, 2008-08-11 at 14:02 -0700, Saya wrote: I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/

Re: RegEx help please ...

2008-08-11 Thread Rob Dixon
Mr. Shawn H. Corey wrote: On Mon, 2008-08-11 at 23:30 +0100, Rob Dixon wrote: Mr. Shawn H. Corey wrote: On Mon, 2008-08-11 at 14:02 -0700, Saya wrote: I have the following issue: my $s = /metadata-files/test-desc.txt,/metadata-files/birthday.txt,/

Re: regex help

2008-07-24 Thread Mr. Shawn H. Corey
On Thu, 2008-07-24 at 09:44 -0400, Tony Heal wrote: I have a text dump of a postgresql database and I want to find out if there are any characters that are not standard keyboard characters. Is there a way to use regex to do this without doing a character by character scan of a 5GB file. No.

regex help

2008-07-24 Thread Tony Heal
I have a text dump of a postgresql database and I want to find out if there are any characters that are not standard keyboard characters. Is there a way to use regex to do this without doing a character by character scan of a 5GB file. I want to know where any character that is not one of these is

Re: Regex help

2008-06-21 Thread Dr.Ruud
Ravi Malghan schreef: I want to split this string into an array using comma seperator, but the problem is some values have one or more commas within them. That is a common problem. First split on comma, then recombine elements by using out-of-band knowledge. -- Affijn, Ruud Gewoon is een

Re: Regex help

2008-06-21 Thread Rob Dixon
Rob Dixon wrote: Ravi Malghan wrote: Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked through http://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string which is a sequence of words and

Regex help

2008-06-20 Thread Ravi Malghan
Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked through http://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string which is a sequence of words and each item is comma seperated field1,

Re: Regex help

2008-06-20 Thread yitzle
On Fri, Jun 20, 2008 at 3:10 PM, Ravi Malghan [EMAIL PROTECTED] wrote: Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked through http://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string

Re: Regex help

2008-06-20 Thread John W. Krahn
Ravi Malghan wrote: Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked through http://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string which is a sequence of words and each item is comma

Re: Regex help

2008-06-20 Thread Rob Dixon
Ravi Malghan wrote: Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked through http://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string which is a sequence of words and each item is

Re: Regex help

2008-06-20 Thread Gunnar Hjalmarsson
Ravi Malghan wrote: I have a string which is a sequence of words and each item is comma seperated field1, lengthof value1, value1,field2, length of value2, value2,field3,length of value3, value3 and so on After each field name I have the length of the value I want to split this string into an

Re: Regex help

2008-06-20 Thread icarus
On Jun 20, 9:10 am, [EMAIL PROTECTED] (Ravi Malghan) wrote: Hi: I am trying to extract some stuff from a string and not getting the expected results. I have looked throughhttp://www.perl.com/doc/manual/html/pod/perlre.html and can't seem to figure this one out. I have a string which is a

Regex help?

2008-05-07 Thread sanket vaidya
HI all, Kindly go through the code below. use warnings; use strict; my $i=1; while($i=10) { $_ = abcpqr; $_=~ s/(?=pqr)/$i/; print $_\n; $i++; } Output: abc1pqr abc2pqr abc3pqr abc4pqr abc5pqr abc6pqr abc7pqr abc8pqr abc9pqr abc10pqr The expected output is

Re: Regex help?

2008-05-07 Thread John W. Krahn
sanket vaidya wrote: HI all, Hello, Kindly go through the code below. use warnings; use strict; my $i=1; while($i=10) { $_ = abcpqr; $_=~ s/(?=pqr)/$i/; print $_\n; $i++; } Output: abc1pqr abc2pqr abc3pqr abc4pqr abc5pqr abc6pqr abc7pqr abc8pqr abc9pqr abc10pqr The expected output is

Re: Regex help?

2008-05-07 Thread Dr.Ruud
sanket vaidya schreef: use warnings; use strict; my $i=1; while($i=10) { $_ = abcpqr; $_=~ s/(?=pqr)/$i/; print $_\n; $i++; } [...] The expected output is abc001pqr [...] Can any one suggest me how to get that output using regex. i.e. Can this happen by making

Extracting TD's from a Text File (Regex Help).

2008-04-08 Thread sara.samsara
TEXT FILE ## td class=PhorumTableRowAlt thread style=padding-left: 0px a href=http://mysite.com/link/here_goes?id=239;LINK/a nbsp;span class=PhorumNewFlag/span/td td class=PhorumTableRowAlt nowrap=nowrap width=150 a

Re: Extracting TD's from a Text File (Regex Help).

2008-04-08 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote: TEXT FILE ## td class=PhorumTableRowAlt thread style=padding-left: 0px a href=http://mysite.com/link/here_goes?id=239;LINK/a nbsp;span class=PhorumNewFlag/span/td td class=PhorumTableRowAlt nowrap=nowrap

Re: Extracting TD's from a Text File (Regex Help).

2008-04-08 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: All I need is to extract the td with class PhorumTableRowAlt thread. snip pen(TXT, links.txt) or die Unable to open file; my @links = TXT; close (TXT); foreach my $link(@links) { While the substring of interest spans over multiple lines, you are dealing with one

Re: Extracting TD's from a Text File (Regex Help).

2008-04-08 Thread Sean Davis
On Tue, Apr 8, 2008 at 8:22 AM, [EMAIL PROTECTED] wrote: TEXT FILE ## td class=PhorumTableRowAlt thread style=padding-left: 0px a href=http://mysite.com/link/here_goes?id=239;LINK/a nbsp;span class=PhorumNewFlag/span/td td

Re: Regex help

2007-11-25 Thread Todd
See the codes below. The trick here is that $ is an special var used to capture the total match string. So in this case, the /[$]/ regexp literal is equal to / [.type=xmlrpc]/. #!/bin/perl $url = 'http://abc.com/test.cgi?TEST=1.type=xmlrpctype=2'; ($r1) = $url =~ /\.type=(.+?)(|$)/; print \$=$\n;

Re: Regex help

2007-11-25 Thread John W . Krahn
On Saturday 24 November 2007 22:59, Todd wrote: See the codes below. The trick here is that $ is an special var used to capture the total match string. So in this case, the /[$]/ regexp literal is equal to / [.type=xmlrpc]/. Right. And that is a character class which says to match *one*

Re: Regex help

2007-11-24 Thread Rob Dixon
howa wrote: Hello, I want to match a query string, e.g. http://abc.com/test.cgi?TEST=1.type=xmlrpctype=2 I want to extract the .type, currently i use $ENV{QUERY_STRING} =~ /\.type=(.+?)(|$)/; # This is okay but back reference seem no good, i rewrite as $ENV{QUERY_STRING} =~

Re: Regex help

2007-11-23 Thread John W . Krahn
On Thursday 22 November 2007 23:23, howa wrote: Hello, Hello, I want to match a query string, e.g. http://abc.com/test.cgi?TEST=1.type=xmlrpctype=2 I want to extract the .type, currently i use $ENV{QUERY_STRING} =~ /\.type=(.+?)(|$)/; # This is okay but back reference seem no good,

Regex help

2007-11-23 Thread howa
Hello, I want to match a query string, e.g. http://abc.com/test.cgi?TEST=1.type=xmlrpctype=2 I want to extract the .type, currently i use $ENV{QUERY_STRING} =~ /\.type=(.+?)(|$)/; # This is okay but back reference seem no good, i rewrite as $ENV{QUERY_STRING} =~ /\.type=(.+?)[$]/; # seem

Re: Regex Help

2007-11-21 Thread Matthew Whipple
Omega -1911 wrote: which isn't an equivalent to yours - it simply makes sure that the record contains 'Powerball:' and at least one digit - but I'm sure it is adequate. My own solution didn't even do this much checking, since I read the OP as saying that all irrelevant data records had been

Re: Regex Help

2007-11-19 Thread Jenda Krynicky
From: Dr.Ruud [EMAIL PROTECTED] Jenda Krynicky schreef: { my $static; sub foo { $static++; ... } } There (the first declared version of) the variable $static is part of the environment of foo(). Don't mistake that for staticness. Maybe I don't know what does

Re: Regex Help

2007-11-13 Thread Dr.Ruud
Jenda Krynicky schreef: if 0 and my $x; creates a static $x I call it a bug. It's called a feature. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regex Help

2007-11-13 Thread Dr.Ruud
Jenda Krynicky schreef: I'd definitely never ever do condition and my $x = blah(); That is what I said. It is technically OK to use it with a condition that can not be decided at compile time, but I still recommend not to use it. -- Affijn, Ruud Gewoon is een tijger. -- To

Re: Regex Help

2007-11-13 Thread Dr.Ruud
Jenda Krynicky schreef: { my $static; sub foo { $static++; ... } } There (the first declared version of) the variable $static is part of the environment of foo(). Don't mistake that for staticness. In Perl 5.8.8 you can enforce $static to be static, like this: { 0 and

Re: Regex Help

2007-11-12 Thread Jenda Krynicky
From: Dr.Ruud [EMAIL PROTECTED] Rob Dixon schreef: Dr.Ruud: John W . Krahn: /Powerball:/ and my @numbers = /\d+/g; I wouldn't use such a conditional my. There is no conditional 'my': it is a de[c]laration. I call it a conditional my. A my can be just a declaration, or a

Re: Regex Help

2007-11-11 Thread John W . Krahn
On Saturday 10 November 2007 06:39, Dr.Ruud wrote: Jonathan Lang schreef: while (DATA) { ($a[0], $a[1], $a[2], $a[3], $a[4], $b) = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/; push @common, @a; push @powerball, $b; } A slightly different way to do that, is:

Re: Regex Help

2007-11-11 Thread Dr.Ruud
John W . Krahn schreef: Dr.Ruud: Jonathan Lang: while (DATA) { ($a[0], $a[1], $a[2], $a[3], $a[4], $b) = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/; push @common, @a; push @powerball, $b; } A slightly different way to do that, is: while (DATA) { if (my

Re: Regex Help

2007-11-11 Thread Rob Dixon
Dr.Ruud wrote: John W . Krahn schreef: Dr.Ruud: Jonathan Lang: while (DATA) { ($a[0], $a[1], $a[2], $a[3], $a[4], $b) = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/; push @common, @a; push @powerball, $b; } A slightly different way to do that, is: while (DATA) {

Re: Regex Help

2007-11-11 Thread Omega -1911
which isn't an equivalent to yours - it simply makes sure that the record contains 'Powerball:' and at least one digit - but I'm sure it is adequate. My own solution didn't even do this much checking, since I read the OP as saying that all irrelevant data records had been removed. I

Re: Regex Help

2007-11-11 Thread Dr.Ruud
Rob Dixon schreef: Dr.Ruud: John W . Krahn: /Powerball:/ and my @numbers = /\d+/g; I wouldn't use such a conditional my. There is no conditional 'my': it is a de[c]laration. I call it a conditional my. A my can be just a declaration, or a declaration and an initialisation. In this

Regex Help

2007-11-10 Thread Omega -1911
Hello, Can anyone assist with a regex to pull lottery numbers from a page? The following is one example I have tried: All data from the web page is pushed into an array. ( Header and footer info is removed before being pushed into the array.) The entire goal here is an exercise I was playing

Re: Regex Help

2007-11-10 Thread joy_peng
On Nov 10, 2007 5:10 PM, Omega -1911 [EMAIL PROTECTED] wrote: What I will need to be able to do is place the most common 5 numbers (before the word powerball) into an array then place the powerball numbers into another array. Thanks in advance. @liners = split

Re: Regex Help

2007-11-10 Thread Jonathan Lang
Omega -1911 wrote: @liners = split /(\s\[0-9],\s)Powerball:\s[0-9]/,$data_string; Instead of split, just do a pattern match: ($a[0], $a[1], $a[2], $a[3], $a[4], $b) = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/; This puts the first five numbers into the array @a, and puts the

Re: Regex Help

2007-11-10 Thread Dr.Ruud
Jonathan Lang schreef: while (DATA) { ($a[0], $a[1], $a[2], $a[3], $a[4], $b) = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/; push @common, @a; push @powerball, $b; } A slightly different way to do that, is: while (DATA) { if (my @numbers = /(\d+),

Re: Regex Help

2007-11-10 Thread Omega -1911
Thank you both Dr.Ruud Jonathan Lang. I will give both examples a try later today and let you know how it all turns out. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Regex Help

2007-11-10 Thread Omega -1911
Thank you both Dr.Ruud Jonathan Lang. I will give both examples a try later today and let you know how it all turns out. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: regex help

2007-09-26 Thread [EMAIL PROTECTED]
On Sep 25, 4:33 pm, [EMAIL PROTECTED] (Rob Dixon) wrote: Jonathan Lang wrote: Rob Dixon wrote: Jonathan Lang wrote: I'm trying to devise a regex that matches from the first double-quote character found to the next double-quote character that isn't part of a pair; but for some reason,

regex help

2007-09-25 Thread Jonathan Lang
I'm trying to devise a regex that matches from the first double-quote character found to the next double-quote character that isn't part of a pair; but for some reason, I'm having no luck. Here's what I tried: /(.*?)(?!)/ Sample text: author: Jonathan Dataweaver Lang key=val What I'm

Re: regex help

2007-09-25 Thread Rob Dixon
Jonathan Lang wrote: I'm trying to devise a regex that matches from the first double-quote character found to the next double-quote character that isn't part of a pair; but for some reason, I'm having no luck. Here's what I tried: /(.*?)(?!)/ Sample text: author: Jonathan Dataweaver

Re: regex help

2007-09-25 Thread Jonathan Lang
Rob Dixon wrote: Jonathan Lang wrote: I'm trying to devise a regex that matches from the first double-quote character found to the next double-quote character that isn't part of a pair; but for some reason, I'm having no luck. Here's what I tried: /(.*?)(?!)/ Sample text:

Re: regex help

2007-09-25 Thread Rob Dixon
Jonathan Lang wrote: Rob Dixon wrote: Jonathan Lang wrote: I'm trying to devise a regex that matches from the first double-quote character found to the next double-quote character that isn't part of a pair; but for some reason, I'm having no luck. Here's what I tried: /(.*?)(?!)/ Sample

Re: Regex help

2007-09-04 Thread Beginner
On 3 Sep 2007 at 17:44, Rob Dixon wrote: Beginner wrote: I am trying to come up with a regex to squash multiple commas into one. The line I am working on looks like this: SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS, , , , , ,

Regex help

2007-09-03 Thread Beginner
Hi, I am trying to come up with a regex to squash multiple commas into one. The line I am working on looks like this: SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS, , , , , , , , , , There are instances of /,\s{1,},/ and /,,/ The bit

Re: Regex help

2007-09-03 Thread John W. Krahn
Beginner wrote: Hi, Hello, I am trying to come up with a regex to squash multiple commas into one. The line I am working on looks like this: SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS, , , , , , , , , , There are instances of

RE: Regex help

2007-09-03 Thread Andrew Curry
Christ That's certainly 1 way ;) -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: 03 September 2007 16:11 To: Perl beginners Subject: Re: Regex help Beginner wrote: Hi, Hello, I am trying to come up with a regex to squash multiple commas into one. The line I

RE: Regex help

2007-09-03 Thread Andrew Curry
help Christ That's certainly 1 way ;) -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: 03 September 2007 16:11 To: Perl beginners Subject: Re: Regex help Beginner wrote: Hi, Hello, I am trying to come up with a regex to squash multiple commas into one

RE: Regex help

2007-09-03 Thread Beginner
On 3 Sep 2007 at 16:15, Andrew Curry wrote: Think s/(\,+\s*)+/,/g; Should work It produces SPEED OF LIGHT,LIGHT SPEED,TRAVEL,TRAVELLING,DANGER,DANGEROUS,PHYSICAL,CONCEPT,CONCEPTS If that's what you want. Exactly what I want. Thanx, Dp. -- To unsubscribe, e-mail: [EMAIL

RE: Regex help

2007-09-03 Thread Beginner
On 3 Sep 2007 at 16:12, Andrew Curry wrote: $ perl -le' $_ = q[SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS, , , , , , , , , , ]; print; s/,\s*(?=,)//g; print; ' SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, ,

Re: Regex help

2007-09-03 Thread John W. Krahn
Beginner wrote: On 3 Sep 2007 at 16:12, Andrew Curry wrote: Please do not attribute to Andrew Curry a post that was actually submitted by me (see my name at the end there.) TIA $ perl -le' $_ = q[SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, ,

Re: Regex help

2007-09-03 Thread Rob Dixon
Beginner wrote: I am trying to come up with a regex to squash multiple commas into one. The line I am working on looks like this: SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS, , , , , , , , , , There are instances of /,\s{1,},/ and

Re: Regex help

2007-09-03 Thread John W. Krahn
Andrew Curry wrote: Think s/(\,+\s*)+/,/g; Commas are not special in a regular expression so there is no need to escape them. You are using capturing parentheses but are not using the string captured in $1, better to use non-capturing parentheses. s/(?:,+\s*)+/,/g; A modified pattern

Re: Regex help

2007-09-03 Thread John W. Krahn
[ Please do not top-post. TIA ] [EMAIL PROTECTED] wrote: Hi Hello, Unless Perl is the only tool available to you in your toolbox and if you're running Linux or similar consider the tr -s command in a shell. Perl also has that: tr/,//s; perldoc perlop However if you are strictly

RE: Regex help

2007-09-03 Thread asmith9983
16:11 To: Perl beginners Subject: Re: Regex help Beginner wrote: Hi, Hello, I am trying to come up with a regex to squash multiple commas into one. The line I am working on looks like this: SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, , DANGER,DANGEROUS,PHYSICAL, , CONCEPT,CONCEPTS

Re: regex help

2007-08-22 Thread Mumia W..
On 08/21/2007 07:41 AM, Tony Heal wrote: the list is a list of files by version. I need to keep the last 5 versions. Jeff's code works fine except I am getting some empty strings at the beginning that I have not figured out. Here is what I have so far. Lines 34 and 39 are provide a print out

  1   2   3   >