cases.
Do you think that Alex would want to match 192.168.10.10 ? I think so,
but your regex wouldn't.
See $Bill's reply, or the original Cookbook expression, for a much
better suggestion.
But to get back to one of the questions that Alex originally asked:
alex p wrote:
I have
t; [aDc]
true for "a" but not for "aa", or true for "D" but not for "aDc".
\d => 0 1 2 3 4 5 6 7 8 9
[01]? => match zero or more occurrence of 0 OR 1.
[0-4] => 0 1 2 3 4, but not all of them at same time.
now your code:
[0-254] => will match 0
digit 254 or less".
or
"two digit 54 or less"."three digit 254 or less"."three digit 254 or
less"."three digit 254 or less"
- Original Message -
From: "alex p" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Mo
alex p wrote:
> Hello all,
> I have been trying to find a regex to validate IP ranges and found the
> following:
>
> m{
>^ ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
> \. ( \d | [01]?\d\d | 2[0-4]\d | 25[0-5] )
> \. ( \d | [01]?\d\d | 2[0-4]\d | 25
think that cookbook regex is crap but anyways)
your regex fails for a number of reasons.
what you have there is looking to match ip in format of"two digits"."two
digits"."two digits"."two digits".
you regex should be
if($num =~ /^[0-9]\.[0-9]\.[0-9]\.[0-9]$/
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}/) {
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Wenjie Wang
Sent: Tuesday, December 30, 2003 2:37 PM
To: Rob Dixon; Wenjie Wang; [EMAIL PROTECTED] ActiveState. com
Subject: RE: regex questions
:-Original Message-
:From: Rob Dixon [mailto:[EMAIL
:-Original Message-
:From: Rob Dixon [mailto:[EMAIL PROTECTED]
[snap]
:
:>
:> for issue 1), I can do something like:
:> $myDataLine =~ /\s+M\s+\d{1,2}:\d{1,2}\s+(\w+\s\w+\s\w+|\w+\s\w+|\w+)/i;
:> $1 is the value I want.
:> It'll be nice if there is a more generic expression for it.
:
:Unles
Wenjie Wang wrote:
>
> I managed to sort out following regex issues, but I'd like to deal with
them
> in an elegant fashion:-) Suggestions?
>
> 1) extract one, two or more words in a line. The word/phases is separated
> by more the
Beckett Richard-qswi266 wrote:
> Guys,
>
> Someone must have already done this, but I know I can't!
>
> I have an input file name, and using:
> use File::Basename;
> fileparse_set_fstype("MSWin32");
> my $file = fileparse ("$ARGV[0]");
> my $path = dirname ("$ARGV[0]");
>
> I am splitting the
Guys,
Someone must have already done this, but I know I can't!
I have an input file name, and using:
use File::Basename;
fileparse_set_fstype("MSWin32");
my $file = fileparse ("$ARGV[0]");
my $path = dirname ("$ARGV[0]");
I am splitting the input file name into $file and $path.
I can handle t
sorry,
\.[a-zA-Z]{2-4})\s*$
is wrong,
\.[a-zA-Z]{2,4})\s*$
is ok.
regards
Friedel Wittrock
-Ursprüngliche Nachricht-
Von: Huub Peters [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 6. November 2003 09:42
An: [EMAIL PROTECTED]
Betreff: Regex in Mail::BulkMail
I'm using an
,
Huub
- Original Message -
From: "Huub Peters" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 06, 2003 9:41 AM
Subject: Regex in Mail::BulkMail
> I'm using an older version of Mail::BulkMail that contains a regex to
> validate an e-mail
I guess
\.[a-zA-Z]{2-4})\s*$
is the answer, not tested
regards
Friedel Wittrock
-Ursprüngliche Nachricht-
Von: Huub Peters [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 6. November 2003 09:42
An: [EMAIL PROTECTED]
Betreff: Regex in Mail::BulkMail
I'm using an older versi
Huub Peters wrote:
> I'm using an older version of Mail::BulkMail that contains a regex to
> validate an e-mail address. Problem is that it only excepts 2 or 3
> letters after the last dot. Nowadays we have new stuff like [EMAIL PROTECTED]
> that doesn't pass this regex.
>
I'm using an older version of Mail::BulkMail that contains a regex to
validate an e-mail address. Problem is that it only excepts 2 or 3
letters after the last dot. Nowadays we have new stuff like [EMAIL PROTECTED]
that doesn't pass this regex.
return $1 if $email =~ m<
I agree that it seems a bit off but the regex in JavaScript is derived
from Perl so i can understand why he posted to this list.
- Original Message -
From: "Javier Nunez" <[EMAIL PROTECTED]>
To: "perl users" <[EMAIL PROTECTED]>
Sent: Wednesday, Novemb
eck if the starting task was the same, convert time again
Then calcul the difference in seconds.
Regards,
Christophe GAUDER
-Message d'origine-
De : ashish srivastava [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 23 octobre 2003 8:19
À : [EMAIL PROTECTED]
Objet : Regex
Hi ,
I need to parse a
: [EMAIL PROTECTED]Betreff: Re: Regex
question.Ooops:
perldoc perlre gives a
little more on \B or try: http://www.perldoc.com/perl5.8.0/pod/perlfaq6.html#Why-don't-word-boundary-searches-with-%5cb-work-for-me-
a Andy Bach, Sys. ManglerInternet: [EMAIL PROTECTED]
VOICE: (608) 261
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
Thank you for your help. Using binmode was indeed the solution.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
More testing shows that...
These two statements fail:
print "\nYES\n" if $data =~ /\x0D/s;
print "\nYES\n" if $data =~ /\x0d/s;
These two statements succeed:
print "\nYES\n" if $data =~ /\x0A/s;
print "\nYES\n" if $data =~ /\x0a/s;
As I stated before two different HEX editors show od oa sequence
t; To: 'Arms, Mike'; '[EMAIL PROTECTED]'
> Subject: RE: RegEx to remove \x0D\x0A
>
>
> More testing shows that...
>
> These two statements fail:
> print "\nYES\n" if $data =~ /\x0D/s;
> print "\nYES\n" if $data =~ /\x0d/s;
>
> The
Original Message-
From: Arms, Mike [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 01, 2003 2:15 PM
To: Bullock, Howard A.
Subject: RE: RegEx to remove \x0D\x0A
Did you add these two lines after reading in the file?
print "len=", length( $data ), "\n";
print "data=&
For #1 and #2 below: The file has data. I have examined it in two different
Hex editors and printed it to the display.
For #3: my script has 'local $/'. Outlook though it was being helpful. :(
I guess a simple question is should this be working? If so, I will continue
to work with it.
-
The final script will work against data file that I do not have. I am
attempting to help someone else and hit this issue.
The actual string to be removed is "\x20\x1B\x0D\x0A". In testing I can find
the other characters but the RegEx engine does not seem to recognize the
CRLF. You c
Bullock, Howard A. [EMAIL PROTECTED] wrote:
> My script slurps in a file
>
> Local $/;
> $data = ;
>
> and want to remove the CRLF's. but even a simple RegEx match does not
> succeed for me.
>
> These all have failed.
>
> print "\nYES\n" if
Title: RE: RegEx to remove \x0D\x0A
Are you sure they are CRLF's? And why regex? Why not chomp?
Can you give us a bit of actual data?
-Original Message-
From: Bullock, Howard A. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 01, 2003 12:14 PM
To: '[EMAIL PROTECTED
My script slurps in a file
Local $/;
$data = ;
and want to remove the CRLF's. but even a simple RegEx match does not
succeed for me.
These all have failed.
print "\nYES\n" if $data =~ /\015\012/;
print "\nYES\n" if $data =~ /\015\012/s;
print "\nYES\n" if
On Thu, 18 Sep 2003, Ted Schuerzinger wrote:
> This, I suppose, is proof that computers are only as bright as the people
> who program them, and a good lesson on being careful what you look for in
> your regexes :-)
>
> I've noticed that spammers sometimes try to get around people's spam
> fi
;[EMAIL PROTECTED]>
To: "Bayete Leriche" <[EMAIL PROTECTED]>
Subject: Cool university degree deal for everybody!
Well, it *does* match the regex, after all! :-)
--
Ted Schuerzinger, [EMAIL PROTECTED]
___
Perl-Win32-Users m
t: Tuesday, September 02, 2003
12:26 PMTo: Perl UsersSubject: Regex Help
Needed
I have a list of characters. I need to get
a list of all possble sequences of these characters for example.
I have a string that consists of '-mevqgn' I need
to pattern match any combinat
$Bill Luebkert wrote:
> Dax T. Games wrote:
>
>
>>I have a list of characters. I need to get a list of all possble
>>sequences of these characters for example.
>>
>>I have a string that consists of '-mevqgn' I need to pattern match any
>>combination of 'mevqgn' with a preceding - or --.
>>
>
At 01:26 PM 9/2/2003, Dax T. Games wrote:
I have a
list of characters. I need to get a list of all possble sequences
of these characters for example.
I have a string that consists of '-mevqgn' I
need to pattern match any combination of 'mevqgn' with a preceding - or
--.
Right now this is w
pha2) {print "Pattern found!\n";}
-Original Message-From: Dax T. Games
[mailto:[EMAIL PROTECTED]Sent: Tuesday, September 02, 2003
11:26 AMTo: Perl UsersSubject: Regex Help
Needed
I have a list of characters. I need to get
a list of all possble sequences of these cha
or ( @test )
{
print "$_ " . is_DTG_Option( $_ ) . "\n";
}
--
Mike Arms
-Original Message-
From: Dax T. Games [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 02, 2003 11:26 AM
To: Perl Users
Subject: Regex Help Needed
I have a list of characters. I nee
Users" <[EMAIL PROTECTED]>
Sent: Tuesday, September 02, 2003 12:26 PM
Subject: Regex Help Needed
I have a list of characters. I need to get a list of all possble
sequences of these characters for example.
I have a string that consists of '-mevqgn' I need to pattern match a
his assumes that the alphabetic string
you want to match will be 6 characters long. If it could be of any
arbitratry length but only consisting of the characters mevgn then
the patters might be: /^-{1,2}[mevgn]*/. This also assumes that
you are matching the beginning of a string.
The regex u
} }
return 1;}
-Original Message-From: Dax T. Games
[mailto:[EMAIL PROTECTED]Sent: Tuesday, September 02, 2003 1:26
PMTo: Perl UsersSubject: Regex Help
Needed
I have a list of characters. I need to get
a list of all possble sequences of these characters for exampl
Have you tried playing around with character sets? Something like
$target = 'mevqgn';
$length_target = length $target;
if ( $LS_Val =~ /-{1,2}[$target]{$length_target}/ ) {
#do something
}
Whether the above would work for you would depend on whether the code
can ignore positive matches on $LS_
I wanted to use tr but was uanble to accomplish the
task that way. So I used regex like the following:
use strict;
my %MCTWW = qw(m -1 e -1 v -1 q -1 g -1 n -1);my $MyCharsToWorkWith =
\%MCTWW;
$_ = '--mepqgn ';
if ( ! /-{1,2}(\S+)/ ) { printf "Expecting a
Dax T. Games wrote:
> I have a list of characters. I need to get a list of all possble
> sequences of these characters for example.
>
> I have a string that consists of '-mevqgn' I need to pattern match any
> combination of 'mevqgn' with a preceding - or --.
>
> Right now this is what I am d
I have a list of characters. I need to get a
list of all possble sequences of these characters for example.
I have a string that consists of '-mevqgn' I need
to pattern match any combination of 'mevqgn' with a preceding - or
--.
Right now this is what I am doing but it is very
ugly a
Will of Thornhenge wrote:
> I'm doing some work with mail headers that involves converting
> timestamps to a standard format. The following regex works except for
> one pesky trailing close parens.
>
> Here's a sample of the data that causes problems:
>
> ==samp
quot;perl-win32-users Mailing List"
<[EMAIL PROTECTED]>
Sent: Friday, August 01, 2003 8:54 PM
Subject: Help with regex
> I'm doing some work with mail headers that involves converting
> timestamps to a standard format. The following regex works except for
> one pesky trailing
I'm doing some work with mail headers that involves converting
timestamps to a standard format. The following regex works except for
one pesky trailing close parens.
Here's a sample of the data that causes problems:
==sample data
Date: Fri, 1 Aug 1997 08:10:16 -0700 (PDT)
===
This is
On Tue, 10 Jun 2003, alex p wrote:
> All,
> I am really bad at REGEX's and am in need of help!
> I have a script that asks for users input but I need to check that the input
> begin with "MDS(and a number 0-9)" before proceeding
>
> below is something like what I am doing:
>
> print "ask for input
}
else{print "It worked\n";}
}
From: "Trevor Joerges \[SendMIME Software\]" <[EMAIL PROTECTED]>
To: "alex p" <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]>
Subject: Re: easy newbie REGEX
Date: Tue, 10 Jun 2003 15:57:52 -
quot;alex p" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 3:17 PM
Subject: easy newbie REGEX
> All,
> I am really bad at REGEX's and am in need of help!
> I have a script that asks for users input but I need to check that the
input
&
how about something like:
unless ($answer =~ /^MDS\d/)
{
print "Try again: ";
}
MA
__
Post your free ad now! http://personals.yahoo.ca
___
Perl-Win32-Users mailing list
[
All,
I am really bad at REGEX's and am in need of help!
I have a script that asks for users input but I need to check that the input
begin with "MDS(and a number 0-9)" before proceeding
below is something like what I am doing:
print "ask for input";
chomp ($answer=);
#(not sure which one to use be
On Sat, 12 Apr 2003 19:01:28 +, you wrote:
>Got a quick (simple??) question. I can't seem to find an example of how to
>do it!!
>
>I have the following string:
>
>$test = "my brother is not ok today and i want milk for food"
>
>I'd like to be able to place "is not ok today" in $1 and "want
Title: Message
Hi
Got a quick
(simple??) question. I can't seem to find an example of how to do
it!!
I have the following
string:
$test = "my brother is not ok today and i want milk for
food"
I'd like to be able
to place "is not ok today" in $1 and "want milk" in $2. Should
Carlton,
>>> /[backup,backup last]/i
In re regex, [...] creates a character class, not a list of alternatives.
For alternatives, use |.
/backup|backup last/i
Merrill
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscr
All,
I have some code that looks like:
[snip]
print $toolcmd;
if ($toolcmd =~ /[backup,backup last]/i) {
open (loghandle, ">>" .$BK_LOGDIR . $BKLOGFILE) or die "Cannot create log
file";
print "\n Updating Import Log at $BK_LOGDIR$BKLOGFILE \n";
print "\n Log Updated. \n";
print "\n W
> I'm trying to match a string which would start with http://,
> then a character string where there is one one or more
> instances of "%", followed by one instance of ".com", i.e.
> http://www.%55.com
>
> Here is my current pattern:
> http://.*%+.*(\.com)
>
> However, if there are tw
I'm trying to match a string which would start with http://,
then a character string where there is one one or more
instances of "%", followed by one instance of ".com", i.e.
http://www.%55.com
Here is my current pattern:
http://.*%+.*(\.com)
However, if there are two or more instance
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 t
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 di
On 12/14/2002 10:02 AM, Bill Royds -Perl wrote:
The key is
$count = () = $string =~ /a/g;
Which creates a list context for return of match operator $string =~/regex/g
Then the $count= is asking for a scalar context return of a list, which we all know returns the count of elements in list
The key is
$count = () = $string =~ /a/g;
Which creates a list context for return of match operator $string =~/regex/g
Then the $count= is asking for a scalar context return of a list, which we all know
returns the count of elements in list.
The expression
$count = (@temp) = $string =~ /a/g
On 14.12.2002 11:57 Uhr, "Adrian Brinton" <[EMAIL PROTECTED]> wrote:
>
> #count the occurrences of "a"
> $string = "aaabbbcccddd";
> $count = () = $string =~ /a/g;
> print "Count is $count\n";
>
This is really cool ! I never ever seen this kind of line. Is there any rule
or document snipe or exp
ences of "a"
$string = "aaabbbcccddd";
$count = () = $string =~ /a/g;
print "Count is $count\n";
Adrian Brinton
> - Original Message -
> From: "Coonfield, Ben CONT" <[EMAIL PROTECTED]>
> Date: Thu, 12 Dec 2002 15:12:09 -0500
> To: [EMAIL PROTEC
h then get forced to scalar
# based on composition of $b
$b = ($a =~ tr/a/a/);
# verify we counted the number of 'a's in $a
print $b;
# bye
exit;
-Original Message-
From: Coonfield, Ben CONT [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 12, 2002 12:12 PM
To: [EMAIL PROT
It seems like there should be a simpler way to count the number of
occurrences of a regular expression. For example:
@temp= / Current Value: /g;
$count=@temp;
I don't really care about @temp, I only want to get the value for $count.
So how can I do this without creating a (named) temporary varia
ashes make my client think your reply is your .sig - I
wouldn't use them. Had to cut-n-paste your reply:
Thanks. The main problem I was having was I couldn't find the "e" option for
the RegEx. I did look again and still couldn't find it in "perlre".
You looked
was I couldn't find the "e" option for
the RegEx. I did look again and still couldn't find it in "perlre". My final
code looks like this:
my $x;
$Text =~ s#(.*?)<\/blockquote>#
$x = $1;
$x =~ s/|/\n/;
$x =~ s/>\n//;
sprintf '%s', $x ; #eg
Bullock, Howard A. wrote:
I want to alter some characters in a text variable, but only those
between two markers.
$text = 'axxxccvvvacasdcxaswrefajjawerasdcxaswrefajhhaasera';
I want to specify the start and the end and only change the a's
to 8's between the markers. How do I accomplish this
Dovalle Yankelovich wrote:
hi,
im trying to check if one variable that contain a string is equal to another
in my example the if evaluates to true each time
1)
$tmp1 = "qw"
$tmp2 = "rt"
if ($tmp1 == $tmp2)
{
#some code
}
2)
$tmp1 = "qw"
$tmp2 = "qw"
if ($tmp1 == $tmp2)
{
#some code
hi,
im trying to check
if one variable that contain a string is equal to another
in my example the if
evaluates to true each time
1)
$tmp1 =
"qw"
$tmp2 =
"rt"
if ($tmp1 == $tmp2)
{
#
some code
}
2)
$tmp1 =
"qw"
$tmp2 =
"qw"
if ($tmp1 == $tmp2)
{
#
some code
}
both time i
From: "William Martell" <[EMAIL PROTECTED]>
> -
> Hello Perl Users,
>
> I am curious whether there is a way to search a data store for a list
> of values and if any of those values are matched, replace it with a
> single common value.
>
>
a\n";$data =~ s/$filter/BITE
ME/gi;print "$data\n";
see if
you can figure out how it works, and if you have trouble figuring it out, ask
away...
-Original Message-From: William Martell
[mailto:[EMAIL PROTECTED]] Sent: Monday, October 21, 2002 1:49
PM
Phil Ritchie wrote:
> I'm trying to count occurrences of patterns using
>
> $_ = 'ababcdabcd';
> while ($_ =~ m/\Gab/gc)
> {
> $num++;
> }
> while ($_ =~ m/\Gcd/gc)
> {
> $num++;
> }
> print $num;
>
> But it doesn't work. I have a feeling that I need to employ the pos
> function somewher
Ron Grabowski <[EMAIL PROTECTED]> wrote:
> my $regex = join '|', 'value_garbage1',
> 'value_garbage2',
> 'value_garbage3';
> next if /$regex/;
You might want to say "next if /$regex/o
ED]]On Behalf Of
$Bill Luebkert
Sent: Tuesday, August 13, 2002 12:39 AM
To: Dan Jablonsky
Cc: [EMAIL PROTECTED]
Subject: Re: trying to understand how regex works
Dan Jablonsky wrote:
> Hi all,
> I guess it must be a simple problem, but it's a
> mystery to me.
> I got 30 "fields&qu
On 13/08/2002 06:26:59 perl-win32-users-admin wrote:
>Hi all,
>I guess it must be a simple problem, but it's a
>mystery to me.
[snip question involving regex]
>
>Anybody cares to explain this to me?
Try running your script with
perl -re=debug scriptname.pl 2>re_debug
> open FOUT, ">>/some/path/outputfile.txt";
> open FILE ">/some/path/outputfile.txt") or
die("Error: $!");
open(FILE " while{
> p="N";
> next if (/.*?\|value_garbage1\|.*?/ ||
> /.*?\|value_garbage2\|.*?/ ||
&
$fld1=$newfld1;
> $fld2=$2;
> $fld3=$newfld3;
> $fld4=$4;and so on
> }
> print FOUT "$fld1|$fld2|...|$fld30|\n" if ($p="Y");
> #print the whole thing to the new output
> }
>
> Well, it happens that some of
int FOUT "$fld1|$fld2|...|$fld30|\n" if ($p="Y");
#print the whole thing to the new output
}
Well, it happens that some of the lines are completely
out of whack and the regex simply stops there - it
doesn't exit, no errors but goes into an infinite loop
even though
---
use strict;
use Text::Balanced qw(extract_bracketed);
my $text = '{\f2\fs20 Da biste }{\cs6\f1\cf6\lang
\{#}RES_ID{\cs6\f1\cf6\lang #\}} odaberite';
my($extracted, $remainder) = extract_bracketed($text,'{}');
print "$extracted\n$remainder\n";
print(($extracted =~ /^{.*?\s(.*)\s}$/));
---
{\f2
Run this:
perldoc -q balanced
--
Csaba Ráduly, Software Engineer Sophos Anti-Virus
email: [EMAIL PROTECTED]http://www.sophos.com
US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933
__
You are just awesome Thanx.
Also teaches me a lot too. :-)
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Carl Jolley
> Sent: Tuesday, April 09, 2002 11:51 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Sub
On Wed, 27 Feb 2002 [EMAIL PROTECTED] wrote:
> Why should greedy pattern matching be avoided.
>
> my e.g: here
>
> $_ = "bambam";
>
> #option1.
> print if /.*?m/ ;
> print "\n";
>
> #option2.
> print if /.m/;
> print "\n";
>
> #option3.
> print if/.*m/;
> prin
On Wed, 27 Feb 2002 [EMAIL PROTECTED] wrote:
> Why should greedy pattern matching be avoided.
>
> my e.g: here
>
> $_ = "bambam";
>
> #option1.
> print if /.*?m/ ;
> print "\n";
>
> #option2.
> print if /.m/;
> print "\n";
>
> #option3.
> print if/.*m/;
> prin
regex to swap the signs, i.e. either make all output strings have
leading or trailing signs, regardless of input.
I changed my mind on the justification, the commify construct alters the length in a
manner that could result in a string that is
longer than the input, for the program which utilizes
Carl Jolley wrote:
> On Fri, 15 Feb 2002, Dirk Bremer wrote:
>
>
>>$Bill, it was not you who made a mistake with the benchmark, it was I and in the
>process learned a lot of new things about the
>>Benchmark module, which is a wonderful tool and should be used by anyone who is
>interested in p
be more correctly coded as:
s/(\d{$_[1]})$/\.$1/ if (@_ > 1 && $_[1] > 0);
Won't "and $_[1] > 0" be executed even if @_ == 1?
OTOH, won't $_[1] > 0 be false when @_ > 1 is false,
i.e. could not the condition be safely collapsed to:
if $_[1] >
> Reply-To: "Dirk Bremer" <[EMAIL PROTECTED]>
> From: "Dirk Bremer" <[EMAIL PROTECTED]>
> To: "'Perl Win32 Users Mailing List'"
> <[EMAIL PROTECTED]>
> Subject: Re: Zero-suppression Regex
> Date: Thu, 14 Feb 2002 1
the list has more two elements, move the sign-character
> # from the leftmost position to the position of the rightmost
> # space character.
> if ($i > 1) {substr($self,$i - 1,1) = $c; substr($self,0,1) = ' ';}
> }
>
>
x27; ';}
}
return($self);
}
After running some more benchmarks, this routine is several orders of magnitude faster
than sprinf or a regex.
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters
636-922-9158 ext. 652 fax 636-447-4471
[EMAIL PROTECTED]
www
00';$num = sprintf('%1.2f',$num);},
'regex' => sub {my $num = '0.00';$num =~ s/\b0+(?=\d)//;}});
}
returns:
Benchmark: timing 10 iterations of regex, sprintf...
regex: 2 wallclock sec ( 2.30 usr + 0.00 sys = 2.30 CPU) @ 43402.
Dirk,
If you really want a general solution to get rid of initial zeros without
affecting the remainder of the string, then I stand corrected; a regex would
probably be best. Consider my high horse bruised, following an incident with
a low bridge :-)
One last try though before my horse is
In my instance, the 0+ solution would not produce the results I desire. For example,
imagine the input string is "000.00" as in
a dollar amount. The result I desire is "0.00", while the 0+ method results in "0".
The regex that Joe provided produced my desi
[EMAIL PROTECTED] wrote, on Tuesday, February 12, 2002 12:36 PM
: Why not just use 0+$_ and let perl work its magic. I challenge any of you
: regex "pushers" out there to write a regex that beats this in either speed
: or elegance.
Oh, of course. Duh. I had blinders on from the OP'
Very nice. Thanks.
---
Jim
--- $Bill Luebkert <[EMAIL PROTECTED]> wrote:
> use strict;
>
> my @nums = qw(00123 04 004.01 000 00 0 .0 0.01
> 0012.001 000.0001);
> $_ = join ' ', @nums; # save orig for bottom part
>
> foreach (@nums) {
> print "$_ => ";
> s/(? print "$_\n";
Jim Angstadt wrote:
> Dear Joe and Dirk,
>
> Thanks for getting me to look at assertions.
>
> Expanding the requirement a little,
> here is what I have so far:
>
> my @nums = qw/ 00123 04 004.01 000 00 0 .0
>0.01 0012.001 000.0001 /;
> foreach ( @nums ) {
>s/(\b)0+(?=\d)(\
Dear Joe and Dirk,
Thanks for getting me to look at assertions.
Expanding the requirement a little,
here is what I have so far:
my @nums = qw/ 00123 04 004.01 000 00 0 .0
0.01 0012.001 000.0001 /;
foreach ( @nums ) {
s/(\b)0+(?=\d)(\.*.*)/$1$2/g; # fails on 0.01
print $_,
201 - 300 of 372 matches
Mail list logo