Re: Regex assistance

2005-12-18 Thread Chris Devers
On Sat, 17 Dec 2005, M. Lewis wrote:

> Charles K. Clarkson wrote:
> > M. Lewis  wrote:
> > 
> > : But I don't think the following regex is really doing that:
> > : : /micr[qw]o[-]ca[a]p[k][s]/i
> > : : Suggestions, corrections welcome.
> > 
> >  /Microcap|Micro-cap|MicroCaap|Micrqocap|MicrwoCap|MicroCapks/
> > 
> > One advantage of this regex is that new obfuscations can
> > be added very easily.
> > 
> > 
> > HTH,
> > 
> > Charles K. Clarkson
> 
> Thanks Charles. I see your point. Initially I had that for up to maybe 
> 3 or 4 variations. Then I thought I was improving it via the regex. 
> Your method is certainly clear without even thinking about it a whole 
> lot.
 
... of course, the more robust solution is to just install SpamAssassin.

If you run SA with the Bayesian filtering -- the default now, I think -- 
it should automatically learn to pick up on junk like this over time. 

Plus, it uses a few hundred other metrics for determining if a message 
is spam, including querying whether messages, URLs in messages, and mail 
servers messages flow through are on blacklists. 

Your time and your life is too valuable to spend it thinking this much 
about spam. Take your life back. Just use SpamAssassin and get on with 
more interesting things :-)


-- 
Chris Devers


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regex assistance

2005-12-17 Thread M. Lewis

Charles K. Clarkson wrote:

M. Lewis  wrote:

: But I don't think the following regex is really doing that:
: 
: /micr[qw]o[-]ca[a]p[k][s]/i
: 
: Suggestions, corrections welcome.


 /Microcap|Micro-cap|MicroCaap|Micrqocap|MicrwoCap|MicroCapks/

One advantage of this regex is that new obfuscations can
be added very easily.


HTH,

Charles K. Clarkson


Thanks Charles. I see your point. Initially I had that for up to maybe 3 
or 4 variations. Then I thought I was improving it via the regex. Your 
method is certainly clear without even thinking about it a whole lot.


Thanks,
Mike

--

 IBM: Illustrious Busy Mice
  23:50:01 up 5 days,  6:59,  7 users,  load average: 0.08, 0.11, 0.23

 Linux Registered User #241685  http://counter.li.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Regex assistance

2005-12-17 Thread Charles K. Clarkson
M. Lewis  wrote:

: But I don't think the following regex is really doing that:
: 
: /micr[qw]o[-]ca[a]p[k][s]/i
: 
: Suggestions, corrections welcome.

 /Microcap|Micro-cap|MicroCaap|Micrqocap|MicrwoCap|MicroCapks/

One advantage of this regex is that new obfuscations can
be added very easily.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Regex assistance

2005-12-17 Thread M. Lewis

I'm trying to match some obfuscations in some spam.

The words that I'm trying to catch are:

Microcap
Micro-cap
MicroCaap
Micrqocap
MicrwoCap
MicroCapks

But I don't think the following regex is really doing that:

   /micr[qw]o[-]ca[a]p[k][s]/i

Suggestions, corrections welcome.

--

 . REALITY.SYS Corrupted - Unable to recover Universe
  23:05:02 up 5 days,  6:14,  6 users,  load average: 0.12, 0.22, 0.49

 Linux Registered User #241685  http://counter.li.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Regex Assistance

2002-01-18 Thread John Edwards

Thanks. That did the trick. Much appreciated.

John

-Original Message-
From: Joshua Colson [mailto:[EMAIL PROTECTED]]
Sent: 17 January 2002 17:58
To: '[EMAIL PROTECTED]'
Subject: RE: Regex Assistance


I've commented out two lines in your code and replaced them with mine.

I think it should work, but let us know if it doesn't.

Good Luck!

Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]


-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 17, 2002 10:43 AM
To: Perl Beginners (E-mail)
Subject: Regex Assistance


Hi group. 

I have the following snippet of code. It's not working and I've been going
round in circles trying to figure out why.

I need a routine that will look at the filename, if that filename already
exists, then add a (1) to the end. I've got the checking for existance
sorted, it's the generation of the new file name that is the issue.

E.g. test.txt exists so create test(1).txt

If test(1).txt exists then create test(2).txt and so on

Here is the problematic code I have so far

-- code --
my ($name, $ext) = split(/\./,$fileoutname);

#if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
if ($name =~ /\((\d)\)$/) { # the \d assumes one character. {1,1} is
just to specify range.
my $number = $1;
$number++;
# $name =~ tr/\(\d\)/\($number\)/;
$name =~ s/\(\d\)$/\($number\)/;# this line should do the
trick.
} else {
$name .= "(1)";
}

$fileoutname = "$name\.$ext";

-- end code --

There's probally some really basic errors in there, and maybe a much better
way of doing it...

TIA

John




--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex Assistance

2002-01-17 Thread John W. Krahn

John Edwards wrote:
> 
> Hi group.

Hello,

> I have the following snippet of code. It's not working and I've been going
> round in circles trying to figure out why.
> 
> I need a routine that will look at the filename, if that filename already
> exists, then add a (1) to the end. I've got the checking for existance
> sorted, it's the generation of the new file name that is the issue.
> 
> E.g. test.txt exists so create test(1).txt
> 
> If test(1).txt exists then create test(2).txt and so on
> 
> Here is the problematic code I have so far
> 
> -- code --
> my ($name, $ext) = split(/\./,$fileoutname);
> 
> if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
> my $number = $1;
> $number++;
> $name =~ tr/\(\d\)/\($number\)/;
> } else {
> $name .= "(1)";
> }
> 
> $fileoutname = "$name\.$ext";
> 
> -- end code --
> 
> There's probally some really basic errors in there, and maybe a much better
> way of doing it...


This should do what you want:

use File::Basename;

my ( $name, $path, $ext ) = fileparse( $fileoutname, '\..*' );

while ( -e "$path$name$ext" ) {
$name .= '(1)' unless $name =~ s/\((\d+)\)$/'('.($1+1).')'/e;
}

$fileoutname = "$path$name$ext";



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex Assistance

2002-01-17 Thread Frank

On Thu, Jan 17, 2002 at 06:16:08PM +, Frank goofed:
> my $num= ($name=~/\((\d+\)/)?$1:1;
> $num++ while(-e "$name($num).$ext");
---end quoted text---

Ah, forgot to paste the tested version back in my bad.

#!/usr/bin/perl
use strict;

my($name,$ext)=('test','foo');

my $num= $name=~/\((d+)\)/?$1:1;# get number or make it 1.

$num++ while -e "$name($num).$ext"; # while the file exists incr num

open O,">$name($num).$ext"; # Make shiny new file.

-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex Assistance

2002-01-17 Thread Frank

On Thu, Jan 17, 2002 at 05:42:31PM -, John wrote:
> -- code --
> my ($name, $ext) = split(/\./,$fileoutname);
> 
> if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
> my $number = $1;
> $number++;
> $name =~ tr/\(\d\)/\($number\)/;
> } else {
> $name .= "(1)";
> }
> 
> $fileoutname = "$name\.$ext";

> my ($name, $ext) = split(/\./,$fileoutname);

Is this on windows? Or could you have name.some.more.ext?


my $num= ($name=~/\((\d+\)/)?$1:1;
$num++ while(-e "$name($num).$ext");


Is a bit more robust as it checks the directory and loops till it
doesn't find a match for the file. IMO FWIW ;)

-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex Assistance

2002-01-17 Thread Briac Pilpré

In article <2FB59B145095D511A7C90050BAC349F31730A3@MAIL>, John Edwards wrote:
> I need a routine that will look at the filename, if that filename already
> exists, then add a (1) to the end. I've got the checking for existance
> sorted, it's the generation of the new file name that is the issue.

Here's a possible way to do it:

#!/usr/bin/perl -w
use strict;


myRename('Sherlock(1).all');

sub myRename {
my $filename = shift;

warn "Can't find '$filename'\n" and return  unless -e $filename;

my $newname;

if ( $filename =~ m!  (.*)  \(  (\d+)  \)  \.  ([^.]+)  $!x ){
        -  ---  _  
   |  | || 
 |
filename   number in () dot  extension  eol
   

$newname = "$1(" . ($2+1) . ").$3";

}
else {

($newname = $filename) =~ s/\.([^.]+)$/(1).$1/;

}
rename ( $filename, $newname )
or warn "Could not rename '$filename' to '$newname'\n" and next;
print "$filename => $newname\n";
}


__END__

-- 
briac
 << dynamic .sig on strike, we apologize for the inconvenience >>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Regex Assistance

2002-01-17 Thread Joshua Colson

I've commented out two lines in your code and replaced them with mine.

I think it should work, but let us know if it doesn't.

Good Luck!

Joshua Colson
Systems Administrator
Giant Industries, Inc.
(480) 585-8714
[EMAIL PROTECTED]


-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 17, 2002 10:43 AM
To: Perl Beginners (E-mail)
Subject: Regex Assistance


Hi group. 

I have the following snippet of code. It's not working and I've been going
round in circles trying to figure out why.

I need a routine that will look at the filename, if that filename already
exists, then add a (1) to the end. I've got the checking for existance
sorted, it's the generation of the new file name that is the issue.

E.g. test.txt exists so create test(1).txt

If test(1).txt exists then create test(2).txt and so on

Here is the problematic code I have so far

-- code --
my ($name, $ext) = split(/\./,$fileoutname);

#if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
if ($name =~ /\((\d)\)$/) { # the \d assumes one character. {1,1} is
just to specify range.
my $number = $1;
$number++;
# $name =~ tr/\(\d\)/\($number\)/;
$name =~ s/\(\d\)$/\($number\)/;# this line should do the
trick.
} else {
$name .= "(1)";
}

$fileoutname = "$name\.$ext";

-- end code --

There's probally some really basic errors in there, and maybe a much better
way of doing it...

TIA

John





Regex Assistance

2002-01-17 Thread John Edwards

Hi group. 

I have the following snippet of code. It's not working and I've been going
round in circles trying to figure out why.

I need a routine that will look at the filename, if that filename already
exists, then add a (1) to the end. I've got the checking for existance
sorted, it's the generation of the new file name that is the issue.

E.g. test.txt exists so create test(1).txt

If test(1).txt exists then create test(2).txt and so on

Here is the problematic code I have so far

-- code --
my ($name, $ext) = split(/\./,$fileoutname);

if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
my $number = $1;
$number++;
$name =~ tr/\(\d\)/\($number\)/;
} else {
$name .= "(1)";
}

$fileoutname = "$name\.$ext";

-- end code --

There's probally some really basic errors in there, and maybe a much better
way of doing it...

TIA

John


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: brainfart...need minor regex assistance

2001-08-16 Thread Torres, Jose (CTG-Fin Sys)

SET HEADING OFF PAGESIZE 0 FEEDBACK OFF

This will output only the result of 513


Jose A. Torres
BUCS Global Production Support
(212) 670-3879 - Office
(800) 774-4156 - Pager
(914) 632-4630 - Home

> -Original Message-
> From: Yacketta, Ronald [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, August 16, 2001 7:43 PM
> To:   [EMAIL PROTECTED]; Beginners (E-mail)
> Subject:  RE: brainfart...need minor regex assistance
> 
> ok, then why does this only print the 1 in 19?
> 
> #!/usr/bin/perl -w
> 
> 
> my  $session = qx(
> sqlplus -S rtdiag/*\@DBNAME <<-!
> SET HEA OFF;
> select count(*) from session_list;
> quit
> !
> );
> #rem leading carrage returns
> $session =~ tr/^\n//;
> #rem leading spaces
> $session =~ s/^\s+//;
> #get the error if we have one
> my ($sesserr,$seserrtxt) = ($session =~ /(.*): (.*)/);
> #get the session count
> my $sessions = ( $session =~ /^(\d+)/ );
> print "1 $session\n";
> print "2 $sessions\n";
> 
> 
> results in
> 1 19
> 
> 
> 2 1
> > -Original Message-
> > From: Curtis Poe [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, August 16, 2001 18:49
> > To: Beginners (E-mail)
> > Subject: Re: brainfart...need minor regex assistance
> > 
> > 
> > --- "Yacketta, Ronald" <[EMAIL PROTECTED]> wrote:
> > > Folks,
> > > 
> > > I am loosing it today, for some odd reason I am banging my 
> > head against the
> > > wall trying to
> > > parse some sql output.
> > > 
> > > I have the following output:
> > > 
> > > SQL> 
> > >   COUNT(*)
> > > --
> > >513
> > > 
> > > I just need the # in a variable (513)
> > > 
> > > could someone slap me silly for some help here?
> > > 
> > > Regards,
> > > Ron
> > 
> > How you get that depends upon where your output is.  Is it in 
> > a scalar?
> > 
> > $output = q/SQL> 
> >   COUNT(*)
> > --
> >513/;
> > my ( $count ) = ( $output =~ /(\d+)/ );
> > 
> > $output will be undef if there are no digits.
> > 
> > Cheers,
> > Curtis Poe
> > 
> > =
> > Senior Programmer
> > Onsite! Technology (http://www.onsitetech.com/)
> > "Ovid" on http://www.perlmonks.org/
> > 
> > __
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute with 
> > Yahoo! Messenger
> > http://phonecard.yahoo.com/
> > 
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: brainfart...need minor regex assistance

2001-08-16 Thread Curtis Poe

--- "Yacketta, Ronald" <[EMAIL PROTECTED]> wrote:
> ok, then why does this only print the 1 in 19?
> 
> #!/usr/bin/perl -w
> 
> 
> my  $session = qx(
> sqlplus -S rtdiag/*\@DBNAME <<-!
> SET HEA OFF;
> select count(*) from session_list;
> quit
> !
> );
> #rem leading carrage returns
> $session =~ tr/^\n//;
> #rem leading spaces
> $session =~ s/^\s+//;
> #get the error if we have one
> my ($sesserr,$seserrtxt) = ($session =~ /(.*): (.*)/);
> #get the session count
> my $sessions = ( $session =~ /^(\d+)/ );
> print "1 $session\n";
> print "2 $sessions\n";
> 
> 
> results in
> 1 19
> 
> 
> 2 1

Your problem is in this line:

my $sessions = ( $session =~ /^(\d+)/ );

You need parentheses around the left side of this expression:

my ( $sessions ) = ( $session =~ /^(\d+)/ );

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: brainfart...need minor regex assistance

2001-08-16 Thread Yacketta, Ronald

ok, then why does this only print the 1 in 19?

#!/usr/bin/perl -w


my  $session = qx(
sqlplus -S rtdiag/*\@DBNAME <<-!
SET HEA OFF;
select count(*) from session_list;
quit
!
);
#rem leading carrage returns
$session =~ tr/^\n//;
#rem leading spaces
$session =~ s/^\s+//;
#get the error if we have one
my ($sesserr,$seserrtxt) = ($session =~ /(.*): (.*)/);
#get the session count
my $sessions = ( $session =~ /^(\d+)/ );
print "1 $session\n";
print "2 $sessions\n";


results in
1 19


2 1
> -Original Message-
> From: Curtis Poe [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 16, 2001 18:49
> To: Beginners (E-mail)
> Subject: Re: brainfart...need minor regex assistance
> 
> 
> --- "Yacketta, Ronald" <[EMAIL PROTECTED]> wrote:
> > Folks,
> > 
> > I am loosing it today, for some odd reason I am banging my 
> head against the
> > wall trying to
> > parse some sql output.
> > 
> > I have the following output:
> > 
> > SQL> 
> >   COUNT(*)
> > --
> >513
> > 
> > I just need the # in a variable (513)
> > 
> > could someone slap me silly for some help here?
> > 
> > Regards,
> > Ron
> 
> How you get that depends upon where your output is.  Is it in 
> a scalar?
> 
> $output = q/SQL> 
>   COUNT(*)
> --
>513/;
> my ( $count ) = ( $output =~ /(\d+)/ );
> 
> $output will be undef if there are no digits.
> 
> Cheers,
> Curtis Poe
> 
> =
> Senior Programmer
> Onsite! Technology (http://www.onsitetech.com/)
> "Ovid" on http://www.perlmonks.org/
> 
> __
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with 
> Yahoo! Messenger
> http://phonecard.yahoo.com/
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




brainfart...need minor regex assistance

2001-08-16 Thread Yacketta, Ronald

Folks,

I am loosing it today, for some odd reason I am banging my head against the
wall trying to
parse some sql output.

I have the following output:

SQL> 
  COUNT(*)
--
   513

I just need the # in a variable (513)

could someone slap me silly for some help here?

Regards,
Ron

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]