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 two
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 ex
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
(
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 o
Punit Jain,
This is not the optimized code but you can refactor it. This works for the
given scenario, no matter the order of input data.
Hope it helps to some extent.
[code]
my $var = '';
my @args = ();
my %hash;
while () {
chomp;
my ($var,$arg) = split /=/,$_,2;
if($var eq '{') {
@args = ();
Hi punit jain,
Please check my comments below.
On Tue, Jan 8, 2013 at 1:28 PM, punit jain wrote:
> Hi ,
>
> I have a file as below : -
>
> {
> test = ("test123");
> test = ("test123","abc");
> test = ("test123","abc","xyz");
> }
> {
> test1 = ("passfile");
> test1 = ("passfile","pasfile1");
> t
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
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
On Sat, 22 Dec 2012 16:45:21 +0530
punit jain 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 :-
[...]
> I am using below r
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
On 10/28/11 Fri Oct 28, 2011 2:15 PM, "Chris Stinemetz"
scribbled:
> On Wed, Oct 19, 2011 at 1:10 AM, Leo Susanto wrote:
>
>> use strict;
>> my %CELL;
>> my %CELL_TYPE_COUNT;
>> my $timestamp;
>> my $hour;
>> while (my $line = ) {
>>if ($line =~ m|\d{1,2}/\d{1,2}/\d{2} ((\d{1,2}):\d{1
On Wed, Oct 19, 2011 at 1:10 AM, Leo Susanto wrote:
> use strict;
> my %CELL;
> my %CELL_TYPE_COUNT;
> my $timestamp;
> my $hour;
> while (my $line = ) {
>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;
>
use strict;
my %CELL;
my %CELL_TYPE_COUNT;
my $timestamp;
my $hour;
while (my $line = ) {
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 =~ /CEL
Maybe this'll be helpful. )
my $time_rx = qr/(?
(? \d{2} )
(?: :\d{2} ){2}
)
/x;
my $cell_record_rx = qr/CELL
\s+
(? \d+)
\s+
(? [^,]+)
On Mon, Oct 17, 2011 at 10:57 PM, Leo Susanto 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
>> ERR
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 =
sprintf("/home/cstinemetz/
Brian Fraser wrote:
On Tue, Oct 18, 2011 at 12:32 AM, Chris Stinemetz
wrote:
/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 anyth
On Tue, Oct 18, 2011 at 12:32 AM, Chris Stinemetz
wrote:
> /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 but 21, the regex is on
>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
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 ()
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
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
"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, HEHTimest
On Mon, Oct 10, 2011 at 4: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 C
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 using
On 5/16/11 Mon May 16, 2011 3:44 PM, "Owen" 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 match
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,/
web-media/images
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,/
> >> web-media/images/bday-after-help.jpg,javascri
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);"
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,/meta
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 l
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.
N
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
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
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
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 a
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 ite
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 sep
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 s
"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
> t
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
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
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=xmlrpc&type=2';
($r1) = $url =~ /\.type=(.+?)(&|$)/;
print "\
howa wrote:
Hello,
I want to match a query string,
e.g.
http://abc.com/test.cgi?TEST=1&.type=xmlrpc&type=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=
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=xmlrpc&type=2
>
> I want to extract the .type, currently i use
>
> $ENV{"QUERY_STRING"} =~ /\.type=(.+?)(&|$)/; # This is okay
>
> but back reference
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
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
"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:
{
"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 uns
"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/
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"
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 initial
> 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 appre
Dr.Ruud wrote:
John W . Krahn schreef:
Dr.Ruud:
Jonathan Lang:
while () {
($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 () {
if (my
John W . Krahn schreef:
> Dr.Ruud:
>> Jonathan Lang:
>>> while () {
>>> ($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
On Saturday 10 November 2007 06:39, Dr.Ruud wrote:
> "Jonathan Lang" schreef:
> > while () {
> > ($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,
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/
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/
"Jonathan Lang" schreef:
> while () {
> ($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 () {
if (my @numbers =
/(\d+), (\d
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
power
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 /(\s\[0-9],\s)Powerbal
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 fo
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
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:
> >
> > /"(.*?)"(?!")/
> >
> > Sam
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 ""Dataweave
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,CONCEPT
[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 am working on looks like this:
SPEED OF LIGHT, , LIGHT SPEED,TRAVEL,TRAVELLING, ,
D
[ 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
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 in
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 /,,
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, , CONCEPT,CON
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, ,
> DANGER,DANGEROU
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: [E
ject: RE: Regex 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 multip
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
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 /,\s{
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 f
Tony Heal am Dienstag, 21. August 2007:
> > -Original Message-
> > From: Chas Owens [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, August 21, 2007 9:50 AM
> > To: [EMAIL PROTECTED]
> > Cc: beginners@perl.org
> > Subject: Re: regex help
> >
> >
On 8/21/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> OK I added this and I keep getting invalid format
>
> foreach (@newValues){print "$_\n";}
> my @versions;
> while (@newValues)
> {
> chomp;
> die "invalid format" unless
> my (
id format at ./trim.pl line 41. (41 is the die line)
Tony Heal
Pace Systems Group, Inc.
800-624-5999
[EMAIL PROTECTED]
> -Original Message-
> From: Chas Owens [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 21, 2007 9:50 AM
> To: [EMAIL PROTECTED]
> Cc: beginners@perl.
> To: [EMAIL PROTECTED]
> Cc: beginners@perl.org
> Subject: Re: regex help
>
> On 8/21/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> > Here is a sample of the versions that I am using.
> snip
>
> Just to clarify, you have a version string with the following format:
&g
On 8/21/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
>
> -Original Message-
> >From: Chas Owens <[EMAIL PROTECTED]>
> >Sent: Aug 21, 2007 10:01 PM
> >To: Jeff Pang <[EMAIL PROTECTED]>
> >Cc: [EMAIL PROTECTED], beginners@perl.org
> >Sub
-Original Message-
>From: Chas Owens <[EMAIL PROTECTED]>
>Sent: Aug 21, 2007 10:01 PM
>To: Jeff Pang <[EMAIL PROTECTED]>
>Cc: [EMAIL PROTECTED], beginners@perl.org
>Subject: Re: regex help
>
>On 8/21/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>s
On 8/21/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
snip
> my @new = map { $_->[0] } sort { $b->[1] <=> $a->[1] or $b->[2] <=>
> $a->[2] or $b->[3] <=> $a->[3] } map { [ $_, split/\D+/ ] } @arr;
snip
While splitting on non-number is a nifty solution, it would break if
the custom tag can contain a num
-Original Message-
>From: Tony Heal <[EMAIL PROTECTED]>
>Sent: Aug 21, 2007 9:25 PM
>To: [EMAIL PROTECTED], beginners@perl.org
>Subject: RE: regex help
>
>Here is a sample of the versions that I am using.
>16.1-17
>16.1-22
>16.1-23
>16.1-39
>16.3-1
On 8/21/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> Here is a sample of the versions that I am using.
snip
Just to clarify, you have a version string with the following format:
{major}{custom tag}.{minor}-{build}
and you want the list sorted by major, then minor, then build.
#!/usr/bin/perl
use
y, August 21, 2007 8:42 AM
> To: beginners@perl.org
> Subject: RE: regex help
>
> 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
> figure
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 for
troubleshooting. Once I get this fixed
Jeff Pang wrote:
-Original Message-
From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]>
Sent: Aug 21, 2007 12:32 PM
To: Jeff Pang <[EMAIL PROTECTED]>
Cc: beginners@perl.org
Subject: Re: regex help
Jeff Pang wrote:
my @new = map { $_->[0] } sort { $b->[1] <
-Original Message-
>From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]>
>Sent: Aug 21, 2007 12:32 PM
>To: Jeff Pang <[EMAIL PROTECTED]>
>Cc: beginners@perl.org
>Subject: Re: regex help
>
>Jeff Pang wrote:
>> use strict;
>> use warnings;
Jeff Pang wrote:
use strict;
use warnings;
my @arr = qw(14-special.4-32
14-special.4-32
14-special.4-33
14-special.4-33
15-special.1-51
15-special.1-51
15-special.1-52
15-special.1-52
15-special.1-52
15-special.1-53
15-special.1-53
15-special.1-53
15-special.1-54
15-special.1-54
15-special.3-44
-Original Message-
>From: Tony Heal <[EMAIL PROTECTED]>
>Sent: Aug 21, 2007 5:50 AM
>To: beginners@perl.org
>Subject: regex help
>
>I have an array that will have these values. Each value is part of a file
>name. I need to keep the highest (numerically)
>5 files and delete the rest. Wha
Tony Heal wrote:
I have an array that will have these values. Each value is part of a file name.
I need to keep the highest (numerically)
5 files and delete the rest. What is the easiest to sort the array.
Break each file name into fields and sort by most significant field to least. Use
the
Dan Sopher wrote:
This works in a one-liner:
$string =~ s/^\s*(.*\S)\s*$/$1/;
Cheers!
Let's compare Dan's one-liner to the solutions in the FAQ (perlfaq4):
$ perl -le'
for ( "\nX\n", "\nX", "X\n", "X", "\n\n\n", "\n", "" ) {
$a = $b = $c = $_;
$d = $a =~ s/^\s*(.*\S)\s*$/$1/;
This works in a one-liner:
$string =~ s/^\s*(.*\S)\s*$/$1/;
Cheers!
-Dan
-Original Message-
From: Dr.Ruud [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 08, 2007 2:05 PM
To: beginners@perl.org
Subject: Re: regex help
Jeff Pang schreef:
> John W. Krahn:
>> Tony Heal:
Jeff Pang schreef:
> John W. Krahn:
>> Tony Heal:
>>> Why doesn't this work? I want to take any leading
>>> or trailing white spaces out.
>>
>> perldoc -q "How do I strip blank space"
>
> Or generally it could be done by,
> $string =~ s/^\s+|\s+$//g;
The g-modifier doesn't mean "generally" no
-Original Message-
>From: "John W. Krahn" <[EMAIL PROTECTED]>
>Sent: Aug 3, 2007 10:37 AM
>To: Perl beginners
>Subject: Re: regex help
>
>Tony Heal wrote:
>> Why doesn't this work? I want to take any leading or trailing white spaces
>
Tony Heal wrote:
Why doesn't this work? I want to take any leading or trailing white spaces out.
perldoc -q "How do I strip blank space"
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.
On 8/2/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> So since '?' will match the last character, group, or class 0 or 1 time the
> it matches the group of whatever happens to
> be in '.*' up to any spaces that are attached to the '$'.
>
> Is that correct?
snip
No, the ? in .*? is not the same as the
ens [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 02, 2007 4:55 PM
> To: [EMAIL PROTECTED]
> Cc: beginners@perl.org
> Subject: Re: regex help
>
> On 8/2/07, Tony Heal <[EMAIL PROTECTED]> wrote:
> snip
> > Why doesn't this work? I want to take any leading or
1 - 100 of 191 matches
Mail list logo