regular expression, this but not that

2011-09-18 Thread Jer A

All,

lets say i want to test if a string contains pig but not dog and/or not 
cat

i tried something like this:

 =~ m/[^dog]|[^cat]|pig/ig

what is the best way of going about this, using one regex?

your help is very much appreciated, 
thanks.

-Jeremy
  ___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression, this but not that

2011-09-18 Thread Glenn Linderman

On 9/18/2011 9:38 PM, Jer A wrote:

All,

lets say i want to test if a string contains pig but not dog 
and/or not cat


i tried something like this:

 =~ m/[^dog]|[^cat]|pig/ig

what is the best way of going about this, using one regex?

your help is very much appreciated,


perhaps the following:
if ($s =~ m/((dog|cat)?.*pig.*(dog|cat)?)/ig   $1 == pig)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression, this but not that

2011-09-18 Thread Gabor Szabo
On Mon, Sep 19, 2011 at 7:38 AM, Jer A jeremy...@hotmail.com wrote:
 All,

 lets say i want to test if a string contains pig but not dog and/or not
 cat

 i tried something like this:

  =~ m/[^dog]|[^cat]|pig/ig

 what is the best way of going about this, using one regex?

 your help is very much appreciated,
 thanks.


Hi Jeremy,

I am not sure why would you want to use only one regex
and IMHO it would be very complex to write that.
It would make your code both unreadable and slow.


I'd use two regexes for that:

if ($str =~ m/pig/ and $str !~ /dog|cat/) {
}

Add the railing /i if you want this to be case insensitive.
The /g is not needed as the first pig will be ok
and the first dog or cat would also be indication that the match should fail.

regards
   Gabor

-- 
Gabor Szabo                     http://szabgab.com/
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression with variable

2006-11-11 Thread Jerry Kassebaum
I have a regular expression problem

how do i use scalar variables in substitution and complex matching?

eg I want the following to work.

$string =~ s/^$variable//;

$string =~ m/^([^$variable]*)/;


thanks in advance for your help.

-Jeremy A.

$x = Cowboy;
$y = ow;
$x =~ s/$y/-/;
print $x;
;
# Output is C-boy

_
Get FREE company branded e-mail accounts and business Web site from 
Microsoft Office Live 
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression question

2006-08-01 Thread Cai, Lucy (L.)
Title:  Regular expression question







I have a file such as:


My $file = c:\temp\zips\ok.txt;


How can I split the $file to get the only path:


My $dir = c:\temp\zips;

My $file = ok.txt;


Thanks in advance!


Lucy



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression question

2006-08-01 Thread Cai, Lucy (L.)
Title: Regular expression question






I have a file such as:


My $file = c:\temp\zips\ok.txt;


How can I split the $file to get the only path:


My $dir = c:\temp\zips;

My $file = ok.txt;


Thanks in advance!


Lucy



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-08-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: Regular expression question



From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Cai, Lucy (L.)Sent: Monday, July 31, 2006 17:21To: 
Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com; 
perl-unix-users@listserv.ActiveState.com; 
[EMAIL PROTECTED]; 
[EMAIL PROTECTED]Subject: Regular 
_expression_ question

I have a file such as: 
My $file = "c:\temp\zips\ok.txt"; 
How can I split the $file to get the only 
path: 
My $dir = "c:\temp\zips"; My $file = "ok.txt"; 
Thanks in advance! 
Lucy
Better to use File::Basename which will break it out foryou. Comes 
as part of std Perl.
Wags ;)
**
This message contains information that is confidential and proprietary to FedEx Freight or its affiliates.  It is intended only for the recipient named and for the express  purpose(s) described therein.  Any other use is prohibited.
**

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-08-01 Thread Joe Discenza
Title: Regular expression question



Cai, Lucy (L.) wrote, on Monday, July 31, 2006 8:21 
PM
: My 
$file = "c:\temp\zips\ok.txt"; 

: How can 
I split the $file to get the only path: 
: My $dir 
= "c:\temp\zips";: My $file = "ok.txt"; 
May I 
suggest you use File:Basename instead of a regex?
Joe
Joseph Discenza, Senior Programmer/Analystmailto:[EMAIL PROTECTED]Carleton 
Inc. http://www.carletoninc.com574.243.6040 
ext. 300Fax: 574.243.6060 


  
  
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  : Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com; 
  perl-unix-users@listserv.ActiveState.com; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]Subject: Regular 
  _expression_ question
  
  I have a file such as: 
  Thanks in advance! 
  Lucy 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RES: Regular expression question

2006-08-01 Thread Fabricio Soares Martins - Site CBN - SGR
Title: Regular expression question



hi 
wagner,

try 
this:


#/perl 
-w

$file = 
'c:\temp\zips\foo\foo2\foo3\ok.txt'; @pa = split (/\\/, $file);$file = 
$pa[$#pa];

for $i 
(0..($#pa-1)) {$dir .= 
"$pa[$i]\\";}

print "directory: 
$dir\n";print "file: $file\n";


fabrício s. 
martins

  -Mensagem original-De: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]Em nome de 
  Wagner, David --- Senior Programmer Analyst --- WGOEnviada em: 
  terça-feira, 1 de agosto de 2006 16:37Para: Cai, Lucy (L.); 
  perl-win32-users@listserv.ActiveState.com; 
  perl-unix-users@listserv.ActiveState.com; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]Assunto: RE: 
  Regular _expression_ question
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Cai, Lucy (L.)Sent: Monday, July 31, 2006 17:21To: 
  Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com; 
  perl-unix-users@listserv.ActiveState.com; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]Subject: Regular 
  _expression_ question
  
  I have a file such as: 
  My $file = "c:\temp\zips\ok.txt"; 
  How can I split the $file to get the only 
  path: 
  My $dir = "c:\temp\zips"; My $file = "ok.txt"; 
  Thanks in advance! 
  Lucy
  Better to use File::Basename which will break it out foryou. 
  Comes as part of std Perl.
  Wags ;)
  **
  This message contains 
  information that is confidential and proprietary to FedEx Freight or its 
  affiliates. It is intended only for the recipient named and for the express 
  purpose(s) described therein. Any other use is prohibited.
  **
  
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression question

2006-04-27 Thread Chris Wagner
At 09:45 PM 4/26/2006 -0400, Cai, Lucy \(L.\) wrote:
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
 
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.

If u just want the word ucmvob then u don't need any of the rest of the
regex u put in there.  And I think the outer parenthesis on the return could
be messing u up too.  Not sure without testing but that could be trying to
return an array.  This will work:

$Output =~ m/ucmvob/ ? return 1 : return 0;

If u want to retain ur previous return format then do this:

return scalar $Output =~ m/ucmvob/; # returns no. of matches i.e. 1 or 0







--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede malis

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression question

2006-04-26 Thread Cai, Lucy \(L.\)
Hi, all,
 
I have a question about regular expression:
 
my code is like this:
**
sub IsPVob
{
my ($Vob) = @_;
 
my $Output = `cleartool lsvob $Vob`;
die IsPVob can't list vob $Vob  if $?;
 
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);

}
**
 
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
 
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.
 
My code does not work, it return 0. Could you please see why it is like
this? or do you have a better idea?
 
Thanks a lot inadvance!
 
Lucy
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-04-26 Thread Timothy Johnson

Well, there are a couple of issues here.  First off, I don't think this
would even compile, because you used /s instead of \s.  Secondly, your
regex is looking for:



.*  zero or more of any character
(unnecessary, since you didn't anchor the start of the
string)

\(ucmvob\)  the string '(ucmvob)'

\s* zero or more whitespace characters

$   the end of the string

--

I think what you might be looking for is something similar to this:

/\(ucmvob\)/

or possibly this:

/\(ucmvob,.*?\)/

which would match 'ucmvob', a comma, and any other text (non-greedy
match) between parentheses.


Of course, I can't test this where I am, but that should get you
started.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Cai, Lucy (L.)
Sent: Wednesday, April 26, 2006 6:46 PM
To: perl-win32-users@listserv.ActiveState.com
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Regular expression question

Hi, all,
 
I have a question about regular expression:
 
my code is like this:
**
sub IsPVob
{
my ($Vob) = @_;
 
my $Output = `cleartool lsvob $Vob`;
die IsPVob can't list vob $Vob  if $?;
 
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);

}
**
 
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
 
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.
 
My code does not work, it return 0. Could you please see why it is like
this? or do you have a better idea?
 
Thanks a lot inadvance!
 
Lucy
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression question

2006-04-26 Thread Ted Schuerzinger
Cai, Lucy (L.) [EMAIL PROTECTED] graced perl with these words of wisdom:

 return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
 
 }
 **
  
 $Output =/vobs/na_mscs_pvob
 /ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
  
 What I want to do is if this tring include word ucmvob, then return 1,
 else return 0.

If I understand your code correctly, you're looking for the string 
(ucmvob) -- note that you don't have anything in your regex between the 
b and the escaped close partentheses.

In $Output, that string doesn't exist, as the b in ucmvob is followed by a 
comma.

-- 
Ted fedya at bestweb dot net
Oh Marge, anyone can miss Canada, all tucked away down there
--Homer Simpson

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression

2005-11-29 Thread Foo Ji-Haw



$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract Kimberly Kim from the string using regular
expression. Is there a way using expression to skip \[characters] (
like \tab ) and search for only real words, maybe between spaces.

Have you thought of using the \t\t\t as a marker for the start of the 
string you want to capture, like:

$string =~ /\t\t\t([^\t]+)/


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular Expression

2005-11-28 Thread Wong, Danny H.
Hi,
I'm trying to figure out how to parse a string with special
characters. 

$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract Kimberly Kim from the string using regular
expression. Is there a way using expression to skip \[characters] (
like \tab ) and search for only real words, maybe between spaces.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression

2005-11-28 Thread Chris Wagner
At 05:40 PM 11/28/2005 -0800, Wong, Danny H. wrote:
$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract Kimberly Kim from the string using regular
expression. Is there a way using expression to skip \[characters] (
like \tab ) and search for only real words, maybe between spaces.


So u want to be able to search for multi word strings, that may or may not
be interrupted by whitespace or other junk characters?

$match = $string =~ m/(Kimberly\W*\s\W*Kim)/s;
@match = $string =~ m/(Kimberly)\W*\s\W*(Kim)/s;
@match = $string =~ m/($firstname)\W*\s\W*($lastname)/s;
($firstname, $lastname) = $string =~ m/($firstname)\W*\s\W*($lastname)/s;

\s is whitespace and \W is any non alphanumeric garbage.  If any high ASCII
characters are valid name letters it's a little more complicated but
basically the same format.





--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede malis

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


A regular expression question -- Emergency

2005-09-30 Thread Cai, Lucy \(L.\)
Hi All,

I am meeting a problem on a regular expression.

My code is like:

$path_elem = $ENV{'CLEARCASE_PN'};

The return value of $path_elem is either 

$path_elem = /ccstore/test/test.pl

Or $path_elem = /ccstore/test 1/test 1.pl  # there is a space in the
path name including the file name too

There is no rule whether there is a space in the path name or not. How
can I handle it in regular expression, because when I pass the value
$path_elem to a function, if there is a space in the path name, it will
treat it 2 file path name, instead of one.

I used the following code

$path_elem = \$ENV{'CLEARCASE_PN'}\;
It works fine for windows, but does not works fine on unix.

I really appriciate your great help.

Thanks

Lucy

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question -- Emergency

2005-09-30 Thread Richard A. Wells

On UNIX you have to escape the whitespace, e.g.

/this path/has spaces

would become

/this\ path/has\ spaces

The expression

$path_elem =~ s{(\s)}{\\$1}gio;

should do the trick.

Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since 
the data itself contains /s and someone might get confused that a / was 
part of the match or substitution, rather than a delimiter. But you 
still could use s///, if you prefer. Also, \\ is necessary in the 
substituion value, since \ itself is a metacharacter in a regex.


Cheers,
Richard

Cai, Lucy (L.) wrote:


Hi All,

I am meeting a problem on a regular expression.

My code is like:

$path_elem = $ENV{'CLEARCASE_PN'};

The return value of $path_elem is either 


$path_elem = /ccstore/test/test.pl

Or $path_elem = /ccstore/test 1/test 1.pl  # there is a space in the
path name including the file name too

There is no rule whether there is a space in the path name or not. How
can I handle it in regular expression, because when I pass the value
$path_elem to a function, if there is a space in the path name, it will
treat it 2 file path name, instead of one.

I used the following code

$path_elem = \$ENV{'CLEARCASE_PN'}\;
It works fine for windows, but does not works fine on unix.

I really appriciate your great help.

Thanks

Lucy

- 
*** Richard A. Wells, [EMAIL PROTECTED], +1.978.371.7425

*** Reality And Wonder, http://www.raw.com/


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question -- Emergency

2005-09-30 Thread Richard A. Wells

On UNIX you have to escape the whitespace, e.g.

   /this path/has spaces

would become

   /this\ path/has\ spaces

The expression

   $path_elem =~ s{(\s)}{\\$1}gio;

should do the trick. 

Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since 
the data itself contains /s and someone might get confused that a / was 
part of the match or substitution, rather than a delimiter.  But you 
still could use s///, if you prefer. Also, \\ is necessary in the 
substituion value, since \ itself is a metacharacter in a regex.


Cheers,
Richard

Cai, Lucy (L.) wrote:


Hi All,

I am meeting a problem on a regular expression.

My code is like:

$path_elem = $ENV{'CLEARCASE_PN'};

The return value of $path_elem is either 


$path_elem = /ccstore/test/test.pl

Or $path_elem = /ccstore/test 1/test 1.pl  # there is a space in the
path name including the file name too

There is no rule whether there is a space in the path name or not. How
can I handle it in regular expression, because when I pass the value
$path_elem to a function, if there is a space in the path name, it will
treat it 2 file path name, instead of one.

I used the following code

$path_elem = \$ENV{'CLEARCASE_PN'}\;
It works fine for windows, but does not works fine on unix.

I really appriciate your great help.

Thanks

Lucy


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question -- Emergency

2005-09-30 Thread $Bill Luebkert
Richard A. Wells wrote:
 On UNIX you have to escape the whitespace, e.g.
 
 /this path/has spaces
 
 would become
 
 /this\ path/has\ spaces
 
 The expression
 
 $path_elem =~ s{(\s)}{\\$1}gio;

The /io is not needed/wanted.

 should do the trick. 
 
 Note that I used {} delimiters (i.e. s{}{}) to make it clearer, since 
 the data itself contains /s and someone might get confused that a / was 
 part of the match or substitution, rather than a delimiter.  But you 
 still could use s///, if you prefer. Also, \\ is necessary in the 
 substituion value, since \ itself is a metacharacter in a regex.

I think it's easier to read this:

my $win32 = $^O =~ /Win32/i;
my $path_elem = $ENV{CLEARCASE_PN};
$path_elem =~ s/ /\ /g if not $win32;

PS: Top-posting is something we try to avoid in these lists.

 Hi All,

 I am meeting a problem on a regular expression.

 My code is like:

 $path_elem = $ENV{'CLEARCASE_PN'};

 The return value of $path_elem is either 

 $path_elem = /ccstore/test/test.pl

 Or $path_elem = /ccstore/test 1/test 1.pl  # there is a space in the
 path name including the file name too

 There is no rule whether there is a space in the path name or not. How
 can I handle it in regular expression, because when I pass the value
 $path_elem to a function, if there is a space in the path name, it will
 treat it 2 file path name, instead of one.

 I used the following code

 $path_elem = \$ENV{'CLEARCASE_PN'}\;
 It works fine for windows, but does not works fine on unix.

 I really appriciate your great help.


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question -- Emergency

2005-09-30 Thread $Bill Luebkert
Richard A. Wells wrote:
 $Bill Luebkert wrote:
 Richard A. Wells wrote:
   
 [...]

 The expression

 $path_elem =~ s{(\s)}{\\$1}gio;
 

 The /io is not needed/wanted.
   
 Right about the /i. That's conventional laziness on my part, as it is
 usually what I want, though it would be detrimental in this case.

Not detrimental - just confusing and unnecessary since there are no
printable characters in the RE.

 And I always use /o unless I'm intentionally interpolating in my
 pattern. Perhaps the regex engine is smart enough these days to infer
 that from the pattern, but it's another piece of conventional laziness.

I almost never use /o unless I'm trying to eke out the last µs from
some code and then it's meaningless if there is no variable to
interpolate in the RE which again confuses the reader.

 I think it's easier to read this:

 my $win32 = $^O =~ /Win32/i;
 my $path_elem = $ENV{CLEARCASE_PN};
 $path_elem =~ s/ /\ /g if not $win32;
   
 Sure. It's a choice. But s/(\s)/\$1/g will handle other whitespace, too.

The problem stmt didn't include other WS and I would hope nobody would be
stupid enough to use any other WS in a filename - I refuse to even use a
space.  ;)

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question -- Emergency

2005-09-30 Thread Richard A. Wells




$Bill Luebkert wrote:

  Richard A. Wells wrote:
  
  
[...]

The _expression_

$path_elem =~ s{(\s)}{\\$1}gio;

  
  
The /io is not needed/wanted.
  

Right about the /i. That's conventional laziness on my part, as it is
usually what I want, though it would be detrimental in this case.

And I always use /o unless I'm intentionally interpolating in my
pattern. Perhaps the regex engine is smart enough these days to infer
that from the pattern, but it's another piece of conventional laziness.

  I think it's easier to read this:

my $win32 = $^O =~ /Win32/i;
my $path_elem = $ENV{CLEARCASE_PN};
$path_elem =~ s/ /\ /g if not $win32;
  

Sure. It's a choice. But s/(\s)/\$1/g will handle other whitespace, too.

  PS: Top-posting is something we try to avoid in these lists.

Sorry. Understood.

R.
-- 
*** Richard A. Wells, [EMAIL PROTECTED], +1.978.371.7425
*** Reality And Wonder, http://www.raw.com/




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression

2005-09-15 Thread Wong, Danny H.
Hi Perl Gurus,
I have a regular expression question.
I have a variable
$Number = 1.2.3.4

When I use the variable $Number as part of my regular expression, the
. character gets interpret as any character. How do I make it a
literal . that I'm searching for?  
Example:
$String = This is a numeric string 1.2.3.411 embedded within another
string 3.4.5.6
$String =~ m/$Number/I; This returns 1.2.3.411 true, when it
shouldn't.

Thanks for your help!

Thanks 
Danny Wong 
SCM Engineer 
PowerTV Inc., 


- - - - - - - Appended by PowerTV, A division of Scientific Atlanta. - - - - - 
- - 
This e-mail and any attachments may contain information that is confidential, 
proprietary, privileged or otherwise protected by law. The information is 
solely intended for the named addressee (or a person responsible for delivering 
it to the addressee). If you are not the intended recipient of this message, 
you are not authorized to read, print, retain, copy or disseminate this message 
or any part of it. If you have received this e-mail in error, please notify the 
sender immediately by return e-mail and delete it from your computer.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread Foo Ji-Haw
Don't know if this works, but have you tried:

$string = 1\\.2\\.3;

- Original Message - 
From: Wong, Danny H. [EMAIL PROTECTED]
To: Sisyphus [EMAIL PROTECTED]; Jan Dubois
[EMAIL PROTECTED]; perl-win32-users
perl-win32-users@listserv.ActiveState.com
Sent: Thursday, September 15, 2005 2:28 PM
Subject: Regular expression


 Hi Perl Gurus,
 I have a regular expression question.
 I have a variable
 $Number = 1.2.3.4

 When I use the variable $Number as part of my regular expression, the
 . character gets interpret as any character. How do I make it a
 literal . that I'm searching for?
 Example:
 $String = This is a numeric string 1.2.3.411 embedded within another
 string 3.4.5.6
 $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
 shouldn't.

 Thanks for your help!

 Thanks
 Danny Wong
 SCM Engineer
 PowerTV Inc.,


 - - - - - - - Appended by PowerTV, A division of Scientific
Atlanta. - - - - - - -
 This e-mail and any attachments may contain information that is
confidential, proprietary, privileged or otherwise protected by law. The
information is solely intended for the named addressee (or a person
responsible for delivering it to the addressee). If you are not the intended
recipient of this message, you are not authorized to read, print, retain,
copy or disseminate this message or any part of it. If you have received
this e-mail in error, please notify the sender immediately by return e-mail
and delete it from your computer.

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread Сергей Черниенко
Hello Danny,

Thursday, September 15, 2005, 9:28:44 AM, You wrote:

WDH $Number = 1.2.3.4

WDH When I use the variable $Number as part of my regular expression, the
WDH . character gets interpret as any character. How do I make it a
WDH literal . that I'm searching for?  
WDH Example:
WDH $String = This is a numeric string 1.2.3.411 embedded within another
WDH string 3.4.5.6
WDH $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
WDH shouldn't.

 If You mean that '1.2.3.4' is a word i.e. has whitespaces before and
 after it, than your pattern have to be

 $String =~ /$Number\b/;

 That match ' 1.2.3.4 ' and do not match '1.2.3.411'. Dots in $Number
 do not affect matching because variable substituted as string. And
 note: 'i' modifier MUST be lowercase.
-- 
Best regards,
 Сергейmailto:[EMAIL PROTECTED]


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread $Bill Luebkert
Wong, Danny H. wrote:

 Hi Perl Gurus,
   I have a regular expression question.
 I have a variable
 $Number = 1.2.3.4
 
 When I use the variable $Number as part of my regular expression, the
 . character gets interpret as any character. How do I make it a
 literal . that I'm searching for?  
 Example:
 $String = This is a numeric string 1.2.3.411 embedded within another
 string 3.4.5.6
 $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
 shouldn't.

Easiest way is
$String =~ m/\Q$Number\E/i;

You can also use quotemeta (look it up) or escape your .'s in $number (ie: 
1\.2\.3\.4).

PS:  It's not good etiquette to CC people who already read the list.
-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread $Bill Luebkert
$Bill Luebkert wrote:

 You can also use quotemeta (look it up) or escape your .'s in $number (ie: 
 1\.2\.3\.4).

That should have been '1\.2\.3\.4' or 1\\.2\\.3\\.4.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perl Regular Expression Problem

2005-08-23 Thread paul_schwotzer
Perl Regular Expression Problem

We are having a problem with Perl's evaluation of regular expressions.

Here is a code snippet:

   # This regular expression is looking for a word ending in s followed
   # by something in parentheses
   # If the while-block is entered, $1 should contain the word ending in s,
   # and the original word is recreated and assigned to the variable $method

   print(  PRE METHOD [$method]\n );
   while ( $method  $method =~ /(\S+)s\s*\(\s*(.+)\s*\)\s*$/ )
   {
  $method = $1 . s;
  print( POST METHOD [$method]\n );
  $retval = ExecuteLAMethod ($retval, $method);
  .
  .
  .


Here is some data from the print statements:

PRE METHOD [Modules(M6833x LA)]
   POST METHOD [Modules]

This looks good, as expected.
After evaluating the regular expression, $1 contains 'Module'.
The program continues:

PRE METHOD [Modules(M6833x LA)]
   POST METHOD [M6833x LAs]

Here is the problem.
The $method variable contains 'Modules(M6833x LA)' and after
evaluating the regular expression, $1 contains 'M6833x LA'.
I would have expected $1 to contain 'Module is in the first case.

This anomaly is causing our regression-test suite to fail.

Here is some data regarding when this anomaly occurs:

Perl 5.6.1 Build 635 - error Never occurs
Perl 5.8.3 Build 809 - error Always occurs
Perl 5.8.7 Build 813 - error occurs on one machine, but does Not occur on 
another

As you can see, we are constrained to an old version of Perl in order to
keep our test suite running.

What is the best way to troubleshoot this kind of error?
Is this a mis-use of Perl variables?
Is there a way to see what is going on inside Perl?

Someone at ActiveState suggested that our code is out-of-date with some
regexpr changes that were made for version 5.8.

Thanks for your help, Paul Schwotzer

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl Regular Expression Problem

2005-08-23 Thread Chris Wagner
It works as expected for me and it's build 811.  At this point I would take
it onto Bugtraq.  Something's not right with ur build

C:\WINDOWS\Desktopperl
$method = 'Modules(M6833x LA)';
$method =~ /(\S+)s\s*\(\s*(.+)\s*\)\s*$/;
$method = $1 . s;
print( POST METHOD [$method]\n );

POST METHOD [Modules]

C:\WINDOWS\Desktopperl -v

This is perl, v5.8.6 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2004, Larry Wall

Binary build 811 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Dec 13 2004 09:52:01

At 03:38 PM 8/23/05 -0600, [EMAIL PROTECTED] wrote:
Here is the problem.
The $method variable contains 'Modules(M6833x LA)' and after
evaluating the regular expression, $1 contains 'M6833x LA'.
I would have expected $1 to contain 'Module is in the first case.
Perl 5.6.1 Build 635 - error Never occurs
Perl 5.8.3 Build 809 - error Always occurs
Perl 5.8.7 Build 813 - error occurs on one machine, but does Not occur on
another




--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede males

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl Regular Expression Problem

2005-08-23 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 Perl Regular Expression Problem
 
 We are having a problem with Perl's evaluation of regular expressions.
 
 Here is a code snippet:
 
# This regular expression is looking for a word ending in s followed
# by something in parentheses
# If the while-block is entered, $1 should contain the word ending in s,
# and the original word is recreated and assigned to the variable $method
 
print(  PRE METHOD [$method]\n );
while ( $method  $method =~ /(\S+)s\s*\(\s*(.+)\s*\)\s*$/ )
{
   $method = $1 . s;
   print( POST METHOD [$method]\n );
   $retval = ExecuteLAMethod ($retval, $method);
   .
   .
   .
 
 
 Here is some data from the print statements:
 
 PRE METHOD [Modules(M6833x LA)]
POST METHOD [Modules]
 
 This looks good, as expected.
 After evaluating the regular expression, $1 contains 'Module'.
 The program continues:

What do you mean the program continues ?  Can you post a complete snippet
that actually fails ?

 PRE METHOD [Modules(M6833x LA)]
POST METHOD [M6833x LAs]
 
 Here is the problem.
 The $method variable contains 'Modules(M6833x LA)' and after
 evaluating the regular expression, $1 contains 'M6833x LA'.
 I would have expected $1 to contain 'Module is in the first case.
 
 This anomaly is causing our regression-test suite to fail.
 
 Here is some data regarding when this anomaly occurs:
 
 Perl 5.6.1 Build 635 - error Never occurs
 Perl 5.8.3 Build 809 - error Always occurs
 Perl 5.8.7 Build 813 - error occurs on one machine, but does Not occur on 
 another
 
 As you can see, we are constrained to an old version of Perl in order to
 keep our test suite running.
 
 What is the best way to troubleshoot this kind of error?
 Is this a mis-use of Perl variables?
 Is there a way to see what is going on inside Perl?
 
 Someone at ActiveState suggested that our code is out-of-date with some
 regexpr changes that were made for version 5.8.


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular Expression Help Please

2005-02-08 Thread steve silvers
One of the columns I'm calling out of my database is the email one. I'ts in 
MAPI format, so I need to extract the very last part. So the bottom example 
I would need to grab

JDoe
MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe
Then I can append the rest as
[EMAIL PROTECTED]
Every one is the same format,
MAPI:{Smith, Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith
Any help greatly appreciated.
Thanks in advance
Steve
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Gerber, Christopher J
-Original Message-
 One of the columns I'm calling out of my database is the email one. I'ts
in MAPI format,
 so I need to extract the very last part. So the bottom example I would
need to grab
 
 JDoe
 
 MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe

Steve,

An easy way might be:

$_ = 'MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
/([^=]+)$/;
print $1;

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be 
privileged. It is intended for the addressee(s) only. Access to this E-mail by 
anyone else is unauthorized. If you are not an addressee, any disclosure or 
copying of the contents of this E-mail or any action taken (or not taken) in 
reliance on it is unauthorized and may be unlawful. If you are not an 
addressee, please inform the sender immediately.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Charles K. Clarkson
From: [EMAIL PROTECTED]  wrote:

: One of the columns I'm calling out of my database is the email
: one. I'ts in MAPI format, so I need to extract the very last
: part. So the bottom example I would need to grab
: 
: JDoe
: 
: MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe
: 
: 
: Then I can append the rest as
: 
: [EMAIL PROTECTED]
: 
: Every one is the same format,
: 
: MAPI:{Smith, Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith
: 
: Any help greatly appreciated.


my $field = 'MAPI:{Smith,
Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith';
my $email;
if ( $field =~ /=([^=]+)$/ ) {
$email = [EMAIL PROTECTED];

} else {
# Uh Oh!
}


The '$' is a zero length placeholder for the end of
the string. [^=] is a character class of all characters
which are not the equal sign. Anything inside parenthesis
'()' will be captured to $1.

HTH,

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

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression Help Please

2005-02-08 Thread Chris Wagner
You can get that plus some other info with this regex:

$string = 'MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
($lastname, $firstname, $mailid) = $string =~ m/^.+?\{(\w+),
(\w+)\}.+?cn\=(\w+)$/;


At 09:46 PM 2/8/05 +, steve silvers wrote:
One of the columns I'm calling out of my database is the email one. I'ts in 
MAPI format, so I need to extract the very last part. So the bottom example 
I would need to grab

JDoe





___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Chris


-Original Message-

One of the columns I'm calling out of my database is the email one. I'ts in 
MAPI format, so I need to extract the very last part. So the bottom example 
I would need to grab

JDoe

MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe


Then I can append the rest as

[EMAIL PROTECTED]

Every one is the same format,

MAPI:{Smith, Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith

Any help greatly appreciated.
Thanks in advance
Steve

---

I know there's probably a better way to do this, but...

my $field='MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
my @bla = split(/=/, $field);
print pop(@bla);


- Chris




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question

2004-11-12 Thread Ted Schuerzinger
$Bill Luebkert graced perl with these words of wisdom:

B. I want to get 1.62 from the string, how can I do it?
 
 
 Nobody seems to have answered part B. 
 
 Actually they did.  Sam's for one :
 
 $string = sct-1.62-1;
 print $1\n if ($string =~ /^.+-(.+)-.+$/);

You mean $1 captures the part in parentheses?

Sometimes, trying to decipher regexes is like trying to read chicken 
scratches  :-)

-- 
Ted fedya at bestweb dot net
Barney: Hey, Homer, you're late for English.
Homer: Who needs English?  I'm never going to England.  
http://www.snpp.com/episodes/7F12.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


A regular expression question

2004-11-11 Thread Cai, Lixin \(L.\)
Title: A regular expression question






Now I have a string like 


My $string = sct-1.62-1;


I have 2 regular _expression_ question here,


A. I want to check whether the format is XXX-XXX-XXX, how can I do it?

B. I want to get 1.62 from the string, how can I do it?


Thanks a lot in advance!


Lixin



Lixin Cai

Security Compliance Tools(SCT)

Location: ITek 2WC135

Phone:313-317-4906

email: [EMAIL PROTECTED]



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: A regular expression question

2004-11-11 Thread Peter Eisengrein
Title: A regular expression question



Your format does not match XXX-XXX-XXX so I'll guess you mean three 
fields delimited by a dash.

 here's one way to do it

$string = "sct-1.62-1"; 
print "$1\n" if ($string =~ /^.+\-(.+)\-.+$/)






  -Original Message-From: Cai, Lixin (L.) 
  [mailto:[EMAIL PROTECTED]Sent: Thursday, November 11, 2004 2:37 
  PMTo: [EMAIL PROTECTED]Subject: 
  A regular _expression_ question
  Now I have a string like 
  My $string = "sct-1.62-1"; 
  I have 2 regular _expression_ question here, 
  
  A. I want to check whether the format is 
  "XXX-XXX-XXX", how can I do it? B. I want 
  to get 1.62 from the string, how can I do it? 
  Thanks a lot in advance! 
  Lixin 
  Lixin Cai Security Compliance 
  Tools(SCT) Location: ITek 
  2WC135 Phone:313-317-4906 email: [EMAIL PROTECTED] 
  
  
  
  
  
  Message transport securityby 
  GatewayDefender2:40:28 PM ET - 
11/11/2004
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: A regular expression question

2004-11-11 Thread Gardner, Sam
Title: Message



or 
even. . .

$string = "sct-1.62-1";print 
"$1\n" if ($string =~ /^.+-(.+)-.+$/);

(no 
need to use the backslash escape for the dashes; they're not part of a character 
class. . .




  
  

  Sam 
  Gardner
  

  GTO Application Development
  

  Keefe, Bruyette  Woods, Inc.
  

  212-887-6753

  
  -Original Message-From: Peter Eisengrein 
  [mailto:[EMAIL PROTECTED] Sent: Thursday, November 11, 2004 
  2:52 PMTo: 'Cai, Lixin (L.)'; 
  [EMAIL PROTECTED]Subject: RE: A regular 
  _expression_ question
  Your format does not match XXX-XXX-XXX so I'll guess you mean three 
  fields delimited by a dash.
  
   here's one way to do it
  
  $string = "sct-1.62-1"; 
  print "$1\n" if ($string =~ /^.+\-(.+)\-.+$/)
  
  
  
  
  
  
-Original Message-From: Cai, Lixin (L.) 
[mailto:[EMAIL PROTECTED]Sent: Thursday, November 11, 2004 2:37 
PMTo: 
[EMAIL PROTECTED]Subject: A regular 
_expression_ question
Now I have a string like 
My $string = "sct-1.62-1"; 
I have 2 regular _expression_ question here, 

A. I want to check whether the format is 
"XXX-XXX-XXX", how can I do it? B. I want 
to get 1.62 from the string, how can I do it? 
Thanks a lot in advance! 
Lixin 
Lixin Cai Security 
Compliance Tools(SCT) Location: ITek 2WC135 Phone:313-317-4906 email: [EMAIL PROTECTED] 





Message transport securityby 
GatewayDefender2:40:28 PM ET - 
11/11/2004
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question

2004-11-11 Thread Ted Schuerzinger
Cai, Lixin (L.) graced perl with these words of wisdom:

 My $string = sct-1.62-1;
 
 I have 2 regular expression question here,
 
 A. I want to check whether the format is XXX-XXX-XXX, how can I do it?
 B. I want to get 1.62 from the string, how can I do it?

Nobody seems to have answered part B.  So, assuming you want the middle 
part (ie, the section between the two dashes), use something like the 
following (untested):

snip

my ($string, @line);

$string = sct-1.62-1;
@line = split /-/, $string;
print $line[1];

/snip

-- 
Ted fedya at bestweb dot net
Barney: Hey, Homer, you're late for English.
Homer: Who needs English?  I'm never going to England.  
http://www.snpp.com/episodes/7F12.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: A regular expression question

2004-11-11 Thread $Bill Luebkert
Ted Schuerzinger wrote:

 Cai, Lixin (L.) graced perl with these words of wisdom:
 
 
My $string = sct-1.62-1;

I have 2 regular expression question here,

A. I want to check whether the format is XXX-XXX-XXX, how can I do it?

This format doesn't actually match the example given.  Maybe he
meant 'AAA-N.NN-N[NN]' or something similar (where [] means optional).

B. I want to get 1.62 from the string, how can I do it?
 
 
 Nobody seems to have answered part B. 

Actually they did.  Sam's for one :

$string = sct-1.62-1;
print $1\n if ($string =~ /^.+-(.+)-.+$/);

 So, assuming you want the middle
 part (ie, the section between the two dashes), use something like the 
 following (untested):
 
 snip
 
 my ($string, @line);
 
 $string = sct-1.62-1;
 @line = split /-/, $string;
 print $line[1];
 
 /snip
 


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


question of regular expression

2004-10-28 Thread Ella Cai
I have one line like this:

$command = '$ldapsearch -x -LLL -h "cds2.ford.com" -b "ou=People, o=Ford,c=US" "uid=$login" uid fordUNIXid';

If condition
{
$command = '$ldapsearch -LLL -h "cds2.ford.com" -b "ou=People, o=Ford,c=US" "uid=$login" uid fordUNIXid'
# which -x need to remove
}

Could anyone let me know by using regular _expression_, how can I get rid of "-x"?

Thanks in advance!

Lixin
		Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: question of regular expression

2004-10-28 Thread Ed Chester
 Could anyone let me know by using regular expression, how can I get rid of
-x?

If that's all you really want, and you know that's the only place it can occur,
then its no problem to use just

s/-x/''/;

(substitute '-x' by '')

ed c

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: question of regular expression

2004-10-28 Thread Ed Chester

i wrote, obviously with my eyes closed: 

   s/-x/''/;

which of course should be s/-x//;  - sorry!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


LWP and Regular Expression

2004-05-07 Thread steve silvers
I'm using LWP::UserAgent to grab data from internal intranet site pages. I 
can grab the page just fine with:

$ua = LWP::UserAgent-new;
$ua-proxy(['http', 'ftp'] = 'http://login:[EMAIL PROTECTED]');
$req = HTTP::Request-new('GET',http://google.com;);

$res = $ua-request($req);
print $res-content if $res-is_success;
I need to grab the page data either in an array or scalar and cut out a 
certain part of text. So if I use

$all = $res-content if $res-is_success;

Then $all contains all the source code of the page. How do I grab out data. 
As an example say I'm grabbing the Google home page. How would I grab out 
the bottom ©2004 Google - Searching 4,285,199,774 web pages text? This is 
just an example to get me started.

Thanks in advance
Steve
_
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
download! http://toolbar.msn.com/go/onm00200413ave/direct/01/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: LWP and Regular Expression

2004-05-07 Thread $Bill Luebkert
steve silvers wrote:

 I'm using LWP::UserAgent to grab data from internal intranet site pages. I 
 can grab the page just fine with:
 
 $ua = LWP::UserAgent-new;
 $ua-proxy(['http', 'ftp'] = 'http://login:[EMAIL PROTECTED]');
 
 $req = HTTP::Request-new('GET',http://google.com;);
 
 $res = $ua-request($req);
 print $res-content if $res-is_success;
 
 I need to grab the page data either in an array or scalar and cut out a 
 certain part of text. So if I use
 
 $all = $res-content if $res-is_success;
 
 Then $all contains all the source code of the page. How do I grab out data. 
 As an example say I'm grabbing the Google home page. How would I grab out 
 the bottom ©2004 Google - Searching 4,285,199,774 web pages text? This is 
 just an example to get me started.

You could use a module or a regex.

Modules like: HTML::Parse, HTML::Parser, HTML::TreeBuilder, etc.

Regex:

$all =~ /Google - Searching ([\d,]+) web pages/s;
my $numpages = $1;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-02 Thread Beckett Richard-qswi266
 So I get:
 
 /^-?(?:\d+\.?\d*|\.\d+)$/

I'm being thrown by the ?:

What's that all about?

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Cai_Lixin
Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Stacy Doss
$a = this is a (test);
$a =~ s/\W+/_/g;

HTH

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question


Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Peter Guzis
$a =~ s/ /_/g;
$a =~ s/[()]//g;

or

$a =~ tr/ ()/_/d;


Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 9:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question


Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2004-04-01 Thread Michael 'topdog' Thompson





Stacy Doss wrote:

  $a = "this is a (test)";
$a =~ s/\W+/_/g;

HTH

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular _expression_ question


Thanks for the replying.

I have another question, if I have a string like 
$a = "this is a (test)";

How can I change it to 
$a = "this_is_a_test";

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular _expression_ question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

  
  
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 16:49
To: [EMAIL PROTECTED]
Subject: regular _expression_ question

I have a $a which

 

$a = "this is a test";

 

How can I change $a like:

 

$a = "this_is_a_test";

 

No problem using $a, but if I were you, I would not.  In the Perl
sort $a, $b are the default variables to use and I would stay away if I
were you.

 

That said,

$a =~ s/ /_/g;

  
  
You could also use tr (slightly faster) :

	$a =~ tr/ /_/;

  


-- 
hi,

you might want to add the following statement after words:

$a =~ s/__/_/g;  # for viewing reasons...

regards,
topdog

"i have slipped the surly bonds of earth, and danced the skies on laughter-silvered wings;" --john gillespie magee jr.
 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression to test for numeric values

2004-04-01 Thread Motter, Jeffrey D
I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to 0( as in zero ).

Examples:
$txtype=2.314;   # is numeric, so keep the value
$txtype=-2.314;  # is numeric, so keep the value
$txtype=7;   # is numeric, so keep the value
$txtype=-7;  # is numeric, so keep the value
$txtype=2.31.4;  # is not numeric, so change the value to 0
$txtype=7-7; # is not numeric, so change the value to 0
$txtype=UNKNOWN; # is not numeric, so change the value to 0
$txtype=7+E09;   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Peter Guzis
$txtype = 0 unless $txtype =~ /^-{0,1}\d+(?:\.\d+){0,1}$/;

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 10:40 AM
To: Perl-Win32-Users
Subject: Regular expression to test for numeric values


I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to 0( as in zero ).

Examples:
$txtype=2.314;   # is numeric, so keep the value
$txtype=-2.314;  # is numeric, so keep the value
$txtype=7;   # is numeric, so keep the value
$txtype=-7;  # is numeric, so keep the value
$txtype=2.31.4;  # is not numeric, so change the value to 0
$txtype=7-7; # is not numeric, so change the value to 0
$txtype=UNKNOWN; # is not numeric, so change the value to 0
$txtype=7+E09;   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Gerber, Christopher J
-Original Message-
My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?
--
I haven't written a regex in a few months, but how about something like
this:

  for (2.314,-2.314,7,-7,2.31.4,7-7,UNKNOWN,7+E09) {
$txtype=$_;
$txtype=0 unless /^-?((\d+)|(\d*\.\d+)|(\d+\.\d*))$/;
print $_ = $txtype\n;
  }

^   match beginning of string
-?  string MIGHT begin with a -
(\d+)   string of numbers with no .
(\d*\.\d+)  string of numbers with a . (digits only required AFTER .)
(\d+\.\d*)  string of numbers with a . (digits only required BEFORE .)
(..|..|..)  pick one of the three options for a match
$   match end of the string

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Joseph Discenza
Gerber, Christopher J wrote, on Thursday, April 01, 2004 2:12 PM
:  -Original Message-
:  My guess is that I need a regex that will match on any character that is:
:   not 0-9 
:   or 
:   more than one . 
:   or 
:   more than one - 
:   or if - is not the first character of the string
:  
:  Any ideas? Is it possible to do without using additional modules?
:  --
:  I haven't written a regex in a few months, but how about something like
:  this:
:  
:for (2.314,-2.314,7,-7,2.31.4,7-7,UNKNOWN,7+E09) {
:  $txtype=$_;
:  $txtype=0 unless /^-?((\d+)|(\d*\.\d+)|(\d+\.\d*))$/;
:  print $_ = $txtype\n;
:}
:  
:  ^match beginning of string
:  -?   string MIGHT begin with a -
:  (\d+)string of numbers with no .
:  (\d*\.\d+)   string of numbers with a . (digits only required AFTER .)
:  (\d+\.\d*)   string of numbers with a . (digits only required BEFORE .)
:  (..|..|..)   pick one of the three options for a match
:  $match end of the string

I'd make just a few suggestions. First, since there's no need for capture,
dispense with the internal capturing parentheses, and make the outer ones
non-capturing. This will speed up the regex engine a little, and if there's
a lot of stuff to go through...

Secondly, if you make your decimal optional in the third alternation,
it's no different from the first, so you can eliminate one of the alternatives.
Then you've also matched those with *any* digits before the decimal, so you
can remove the leading \d* from the other alternative.

So I get:

/^-?(?:\d+\.?\d*|\.\d+)$/

for the regex. Just a slight improvement (and a shorter regex is almost
always more readable, too). You could embed the comments in the regex
(use the /x flag) to make it crystal clear.

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! *  




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Peter Eisengrein
Title: RE: Regular expression to test for numeric values





use Scalar::Util;


if (Scalar::Util::looks_like_number $num)
{
 print Yes, $num is a number\n;
}
else
{
 print no.\n;
}



... found it with perldoc -q number, which also showed a number of regex's that do the same kinda thing




 -Original Message-
 From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 01, 2004 1:40 PM
 To: Perl-Win32-Users
 Subject: Regular _expression_ to test for numeric values
 
 
 I've read the FAQ's on this, but they don't seem to answer 
 the question.
 
 I have a variable that could contain any value( alpha, 
 alpha-numeric, or
 numeric). If the value is NOT numeric, I need to change the 
 variables' value
 to 0( as in zero ).
 
 Examples:
 $txtype=2.314; # is numeric, so keep the value
 $txtype=-2.314; # is numeric, so keep the value
 $txtype=7; # is numeric, so keep the value
 $txtype=-7; # is numeric, so keep the value
 $txtype=2.31.4; # is not numeric, so change the value to 0
 $txtype=7-7; # is not numeric, so change the value to 0
 $txtype=UNKNOWN; # is not numeric, so change the value to 0
 $txtype=7+E09; # is not numeric( even though it really is 
 ), so change
 the value to 0
 
 
 My guess is that I need a regex that will match on any 
 character that is:
  not 0-9 
  or 
  more than one . 
  or 
  more than one - 
  or if - is not the first character of the string
 
 Any ideas? Is it possible to do without using additional modules?
 
 Thanks!
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Dial Joe

How about this (direct from The Perl Cookbook[1])  ??


warn has nondigitsif /\D/;
warn not a natural number unless /^\d+$/; # rejects -3
warn not an integer   unless /^-?\d+$/;   # rejects +3
warn not an integer   unless /^[+-]?\d+$/;
warn not a decimal number unless /^-?\d+\.?\d*$/; # rejects .2
warn not a decimal number unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
warn not a C float
   unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;

The cookbook is the first place I look for this kind of stuff.
HTH,
Joe Dial

[1] 
Perl Cookbook 
Tips and Tricks for Perl Programmers
By Tom Christiansen, Nathan Torkington
1st Edition August 1998 
www.oreilly.com 
ISBN: 1-56592-243-3

Current Version is:
Perl Cookbook, 2nd Edition
By Tom Christiansen, Nathan Torkington
2nd Edition August 2003 
ISBN: 0-596-00313-7
964 pages, $49.95 US, $77.95 CA, £35.50 UK 

-Original Message-
From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 01, 2004 1:40 PM
To: Perl-Win32-Users
Subject: Regular expression to test for numeric values


I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to 0( as in zero ).

Examples:
$txtype=2.314;   # is numeric, so keep the value
$txtype=-2.314;  # is numeric, so keep the value
$txtype=7;   # is numeric, so keep the value
$txtype=-7;  # is numeric, so keep the value
$txtype=2.31.4;  # is not numeric, so change the value to 0
$txtype=7-7; # is not numeric, so change the value to 0
$txtype=UNKNOWN; # is not numeric, so change the value to 0
$txtype=7+E09;   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2004-03-31 Thread $Bill Luebkert
Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression replacement

2003-11-28 Thread Beckett Richard-qswi266
Hi,
 
I would like to know how can I replace the value c:\qqq\www\ to
c:/qqq/www/.
I tried several ways, but didn't manage to.
 
Thanks,
Eran


s!\\!/!g
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression replacement

2003-11-28 Thread shonorio



$Value = 'c:\qqq\www\';
$Value =~ s/\\/\//g;
print $Value ;




De:   [EMAIL PROTECTED] em 28/11/2003 09:15
  GMT

Para:   'Kaufman Eran (StarHome)' [EMAIL PROTECTED]
  [EMAIL PROTECTED]
cc:
Assunto: RE: regular expression replacement

Hi,

I would like to know how can I replace the value c:\qqq\www\ to
c:/qqq/www/.
I tried several ways, but didn't manage to.

Thanks,
Eran


s!\\!/!g
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Tamanho do  Documento: 3,78 KbytesLimite = 1200 Kbytes







___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


regular expression replacement

2003-11-27 Thread Kaufman Eran (StarHome)








Hi,



I would
like to know how can I replace the value c:\qqq\www\ to c:/qqq/www/.

I tried
several ways, but didn't manage to.



Thanks,

Eran








RE: Regular Expression problem?

2003-09-26 Thread Carl Jolley
On Fri, 26 Sep 2003, Xu, Qiang (XSSC SGP) wrote:

 Ted S. wrote:
  Beckett Richard-qswi266 graced perl with these words of wisdom:
  That should have been s/.*\///
 
  Don't you have to escape the period, too?
 
  s/\.*\///

 No, we shouldn't, because here . stands for any single character except a
 new line.


Well you are correct that a . regex character will match a period
but consider if the matched string was 'aaabcd.txt' the unescaped
period followed by * would match the string 'aaa'. Technically you are
correct, you don't have to escape the . character unless of course you
want the match to work correctly.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Ted S. wrote:
 Beckett Richard-qswi266 graced perl with these words of wisdom:
 That should have been s/.*\///
 
 Don't you have to escape the period, too?
 
 s/\.*\///

No, we shouldn't, because here . stands for any single character except a
new line. 

thx,

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression problem?

2003-09-25 Thread Glenn Linderman
On approximately 9/25/2003 6:45 AM, came the following characters from
the keyboard of Xu, Qiang (XSSC SGP):
Hi, all: 

I have a regular expression that I can't understand. 

Suppose $filename is a file name that includes the full path. Say, it is
/u/scan/abc.jpg, 
The regular expression is: $filename =~ s|.*/||;

I only know regular expressions such as s/.../.../, but this has the form of
s|...|...| which I am confuse with. 

Anyone can explain the above regular expression as detailed as possible? 
Any delimiter can be used (other posters were correct about that).  The 
delimiter used affects which delimiter character would need to be 
escaped in the regular expression.  Generally, if something other than / 
is used as the delimiter character, it is chosen because it doesn't 
appear in the regular expression, so that there is no need to escape the 
delimiter character.  Some exceptions to that rule include delimiter 
characters that add additional semantics, such as '.

The expression in this case is stripping off leading directory names, 
probably hoping to leave an unqualified file name in the $filename 
variable.  (Other posters claimed it was stripping the extension, but 
that is incorrect.)

--
Glenn -- http://nevcal.com/
===
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick.  It's ridiculous.
-- Bill Gates
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Strohmeier Ruediger wrote:
 Hi Xu Qiang,
 
 unlike e.g. awk, vi or the shell, perl support different delimiter
 for regexes. When a slash is part of the regex or the substitution
 pattern, they can either be escaped (i.e. \/) or other characters can
 be used as delimiters.  
 
 Thus the regex is equivalent to s/.*\/// and cuts away everything
 including the last slash changing /u/scan/abc.jpg into abc.jpg

Yes, this is the correct result, thank you.

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Glenn Linderman wrote:
 Any delimiter can be used (other posters were correct about that). 
 The delimiter used affects which delimiter character would need to be
 escaped in the regular expression.  Generally, if something other
 than / is used as the delimiter character, it is chosen because it
 doesn't appear in the regular expression, so that there is no need to
 escape the delimiter character.  Some exceptions to that rule include
 delimiter characters that add additional semantics, such as '.
 
 The expression in this case is stripping off leading directory names,
 probably hoping to leave an unqualified file name in the $filename
 variable.  (Other posters claimed it was stripping the extension, but
 that is incorrect.)

Thank you, Glenn, you are right. The book said the purpose is to remove the
path and keep the base name. 
I just couldn't understand the grammar in the expression, Now I can. 

Thanks for everyone who helped me. :)

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perldoc problem was Re: regular expression on military time

2003-07-27 Thread John
On Saturday, July 26, 2003 12:05 AM AEST, Ted S.  wrote:

 On 25 Jul 2003, John McMahon wrote in perl:

 Ted

 When you produced the output of 'set' below how did you get to the
 CLI console (command line interpreter aka DOS prompt)? This console
 was opened in the 'Windows' directory.

 What was different in *HOW* you got to this console *TO HOW* you got
 to the console where you invoked 'perldoc.bat' in your earlier
 message (other than the directory they were opened in)? This console
 was opened in the 'Perl' directory.

 I'm not certain I understand your question?  In all cases, I'm
 opening the console via the same shortcut that I've got in the
 Start menu.  I then use the cd command to change directories if
 need be.  And the console is always opened in the Windows directory.

I'm just trying to get a picture of what you are doing and how you are
doing it to see if I can suggest alternatives that might work. I have
changed the subject as it was getting off topic.

I assume you have installed Perl in the default location 'c:\perl' and
your perl executable directory will be 'c:\perl\bin'. Since you use the
same shortcut all the time and your path variable (as shown previously
by your 'set' output 'PATH=C:\WINDOWS;C:\WINDOWS\COMMAND') does not
include your Perl directory, to run scripts from the CLI console you
would have to run them from the 'c:\perl\bin' directory.

Ahh! I think I see the problem. Your previous postings:

 snip
 C:\Perlperldoc
 Usage: perldoc.bat [-h] [-r] [-i] [-v] [-t] [-u] [-m] [-n program]
[-l] [-
 F] [-X
 ] PageName|ModuleName|ProgramName
perldoc.bat -f PerlFunc
perldoc.bat -q FAQKeywords

 The -h option prints more help.  Also try perldoc perldoc to get
 acquainted with the system.
 /snip

and

snip

C:\Perlperldoc perltoc
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.

/snip

shows you invoking perldoc in the 'c:\Perl' directory. Information
provided so far suggests that this should not work at all, however it
did, just not properly. I think this is probably because you don't have
the perl executable directory (c:\perl\bin) in your path. If you were to
repeat the exercise above in the 'c:\perl\bin' directory, I think it
should work.

If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
change the path variable for the current console session then 'cd' to
another directory and test again. It should work.

If this is the answer, then you need to put 'c:\perl\bin' in your path,
you probably should anyway.

HTH
John

-- 
Regards
   John McMahon  (mailto:[EMAIL PROTECTED])

Tired of Outlook Express/Outlook's messy quoting?
Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread Gerry Green
Just a quick note:

- Original Message - 
From: John [EMAIL PROTECTED]
To: Ted S. [EMAIL PROTECTED]
Cc: Perl-Win32-Users [EMAIL PROTECTED]
Sent: Sunday, July 27, 2003 3:07 AM
Subject: Perldoc problem was Re: regular expression on military time

clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work.

If I remember right, this %path% syntax from the command prompt doesn't work
under command.com.   To change the path like that you'll need to repeat the
current value and include the new entry on the end:

path c:\windows;c:\windows\command;c:\perl\bin



 If this is the answer, then you need to put 'c:\perl\bin' in your path,
 you probably should anyway.

 HTH
 John

 -- 
 Regards
John McMahon  (mailto:[EMAIL PROTECTED])

 Tired of Outlook Express/Outlook's messy quoting?
 Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread Ted S.
On 27 Jul 2003, Gerry Green wrote in perl:

 Just a quick note:
 
 - Original Message - 
 From: John [EMAIL PROTECTED]
 To: Ted S. [EMAIL PROTECTED]
 Cc: Perl-Win32-Users [EMAIL PROTECTED]
 Sent: Sunday, July 27, 2003 3:07 AM
 Subject: Perldoc problem was Re: regular expression on military time
 
clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work. 
 
 If I remember right, this %path% syntax from the command prompt
 doesn't work under command.com.   To change the path like that you'll
 need to repeat the current value and include the new entry on the end:
 
 path c:\windows;c:\windows\command;c:\perl\bin

This doesn't stick when I exit the DOS console.

No, I don't know how to change environment variables or other such fun 
stuff.  And heaven knows the help files/documentation are even more 
meager than what comes with most Perl modules!

-- 
Ted Schuerzinger
Homer Simpson: I'm sorry Marge, but sometimes I think we're the worst 
family in town.
Marge: Maybe we should move to a larger community.
http://www.snpp.com/episodes/7G04.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread John
On Monday, July 28, 2003 1:32 AM AEST, Gerry Green  wrote:

 Just a quick note:

 - Original Message -
 From: John [EMAIL PROTECTED]
 To: Ted S. [EMAIL PROTECTED]
 Cc: Perl-Win32-Users [EMAIL PROTECTED]
 Sent: Sunday, July 27, 2003 3:07 AM
 Subject: Perldoc problem was Re: regular expression on military time

 clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work.

 If I remember right, this %path% syntax from the command prompt
 doesn't work under command.com.   To change the path like that you'll
 need to repeat the current value and include the new entry on the end:

 path c:\windows;c:\windows\command;c:\perl\bin

I am pretty sure it does, I have done that sort of thing for years (back
to DOS 2.1), it certainly works in batch files, but I am not going to
reboot into W98 just to test it.




 If this is the answer, then you need to put 'c:\perl\bin' in your
 path, you probably should anyway.

 HTH
 John


-- 
Regards
   John McMahon  (mailto:[EMAIL PROTECTED])

Tired of Outlook Express/Outlook's messy quoting?
Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression on military time

2003-07-25 Thread Ted S.
On 25 Jul 2003, John McMahon wrote in perl:

 Ted
 
 When you produced the output of 'set' below how did you get to the CLI
 console (command line interpreter aka DOS prompt)? This console was
 opened in the 'Windows' directory.
 
 What was different in *HOW* you got to this console *TO HOW* you got to
 the console where you invoked 'perldoc.bat' in your earlier message
 (other than the directory they were opened in)? This console was opened
 in the 'Perl' directory.

I'm not certain I understand your question?  In all cases, I'm opening the 
console via the same shortcut that I've got in the Start menu.  I then 
use the cd command to change directories if need be.  And the console is 
always opened in the Windows directory.

-- 
Ted Schuerzinger
Homer Simpson: I'm sorry Marge, but sometimes I think we're the worst 
family in town.
Marge: Maybe we should move to a larger community.
http://www.snpp.com/episodes/7G04.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression on military time

2003-07-21 Thread Carl Jolley
On Fri, 18 Jul 2003, Ted S. wrote:

 On 18 Jul 2003, Carl Jolley wrote in perl:

  On Thu, 17 Jul 2003, Ted S. wrote:
 
  On 17 Jul 2003, Tobias Hoellrich wrote in perl:
 
   my @t=(08:00, 23:59, 00:00, aa:00, 24:00,  00:01,
   8:00, 08.00, 36:12, 08:61 ); foreach(@t) {
 unless(/^(\d{2}):(\d{2})$/  $124  $260) {
 
  Forgive my ignorance, since I only use perl for basic things and
  haven't yet gotten to text-munging:
 
  I don't see what in your regex is capturing a $1 and a $2.  (Yes, I
  know what $1 and $2 are for.  You can all stop laughing now.  ;-)
 
 
  The first set of parens maps to $1, the second to $2, etc.

 Thanks, Carl and Bill.  Wouldn't you know that this information about
 parentheses mapping to $1 etc. actually *is* in the mess of documents that
 is the Perl manpages.  :-)  (Specifically, perlre, but who can remember
 what all the different page names actually stand for?)


You don't have to remember each of the perl pod file names. Just
remenber one command: perldoc perltoc.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2003-03-28 Thread thomas . baetzler
[EMAIL PROTECTED] schrieb:
 I have a txt file like the bottom (I use cleardiff to
 compare 2 files and
 get this file):

I would recommend that you look at Parse::RecDescent.

Go grab the distribution from CPAN and have a look
at the tutorial - the first example shows you how to
parse a diff.

http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?site=ftp.funet.fi;join=and;stem=no;arrange=file;case=clike;download=auto;age=;distinfo=3453

HTH,
Thomas
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Gerber, Christopher J
The easiest way to reference all but the first character of a string is
probably:

$rest=substr $var,1;

You could also use a regex.  Maybe search for a line that starts with  and
then return 0 or more characters matching anything after that:

$var=~/^(.*)/;
$rest=$1;

You could also use rindex and select all the characters but one.  Basically,
there are a lot of possibilities... a weekend with the Camel book or perldoc
would probably be rather informative.

Chris

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:58 AM
 To: [EMAIL PROTECTED]
 Subject: RE: regular expression question
 
 
 I have another question,
 
 I have string like  GENERATION 116, How can I get rid of 
 , of the
 string?
 
 Thanks
 
 Lixin
 
 
 
 -Original Message-
 From: Todd Hayward [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:30 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: regular expression question
 
 
 load the file into a file handle, and iterate through it line 
 by line. Pipe
 each line to the file handle (the | is not a typo in the example)...
 
 So,
 
 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };
 
 Hope this helps,
 
 NuTs
 
 
 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 9:40 AM
 Subject: regular expression question
 
 
  Dear all
 
  I have a txt file like the bottom (I use cleardiff to 
 compare 2 files and
  get this file):
 
  I will check whether the line includes 
 ___GENERIC_MULTILINE___ or not,
 if
  it includes, I will get the following information
 
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
 
  without  sign,
 
  How can I do it?
 
  Thanks a lot in advance!
 
  Lixin
 
  
 #
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  24c24,30
   ___GENERIC_MULTILINE___
  ---
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  
 ##
 
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Adam Frielink

 
 I have another question,
 
 I have string like  GENERATION 116, How can I get rid of , of the
 string?

If you want to remove the 1st character if it is a , then use this...

$var =~ s///;
$var =~ s/^//;  #This removes it only if it is the first character
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2003-03-28 Thread viktoras
This  works:

open (INPUT ,your_input.txt) || die $!;
open (OUTPUT,  your_output.txt) || die $!;
while (INPUT) {
if (m/GENERIC_MULTILINE/) {
$_=GENERATION 116
# Impossible dependency
# Needed to prevent FC4700 to CX-series upgrades
DEPEND Navisphere 2.0.0.0.0
DEPEND Navisphere 1.0.0.0.0
GENDEPEND Navisphere 116\n;}
print OUTPUT $_;}
close (OUTPUT);
close (INPUT);
viktoras

[EMAIL PROTECTED] wrote:

Dear all

I have a txt file like the bottom (I use cleardiff to compare 2 files and
get this file):
I will check whether the line includes ___GENERIC_MULTILINE___ or not, if
it includes, I will get the following information
 

GENERATION 116 
# Impossible dependency 
# Needed to prevent FC4700 to CX-series upgrades 
DEPEND Navisphere 2.0.0.0.0 
DEPEND Navisphere 1.0.0.0.0 
GENDEPEND Navisphere 116 

   

without  sign,

How can I do it?

Thanks a lot in advance!

Lixin  

#
3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 

REVISION 02041405.002 
DISPLAYREV 02.04.1.40.5.002 
   

24c24,30
 ___GENERIC_MULTILINE___
---
 

GENERATION 116 
# Impossible dependency 
# Needed to prevent FC4700 to CX-series upgrades 
DEPEND Navisphere 2.0.0.0.0 
DEPEND Navisphere 1.0.0.0.0 
GENDEPEND Navisphere 116 

   

3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 

REVISION 02041405.002 
DISPLAYREV 02.04.1.40.5.002
   

##

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

--
Your favorite stores, helpful shopping tools and great gift ideas. 
Experience the convenience of buying online with [EMAIL PROTECTED] 
http://shopnow.netscape.com/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Cai_Lixin
Thanks a lot for your great help, another question,

if I want to switch all \n to \\n in a string how can I do it?
Like 

$var = This is a book\nThat is a desk\nwho is that man?\n;
I did like 
$var =~ s/\n/\\n/g;

but it does nt work. What is wrong with it?

Thanks

Lixin

-Original Message-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question



Borrowing from the previous example of:

 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };

Add this line: $line =~ s/\//g;

This is what your code block should look like:

open(fHandle, myfile.txt|);
while (defined ($line = fHandle)){
$line =~ s/\//g;
if ($line =~ /generic/ig){
 do something}
   };


The 3rd line will effectively delete any instance of  that it finds. If
you want it to only remove the first instance of  from each line, remove
the g from the end. This makes it global to the string, thus
substituting no character for each  it finds.

HTH,

NuTs


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 10:58 AM
Subject: RE: regular expression question


 I have another question,

 I have string like  GENERATION 116, How can I get rid of , of the
 string?

 Thanks

 Lixin



 -Original Message-
 From: Todd Hayward [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:30 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: regular expression question


 load the file into a file handle, and iterate through it line by line.
Pipe
 each line to the file handle (the | is not a typo in the example)...

 So,

 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };

 Hope this helps,

 NuTs


 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 9:40 AM
 Subject: regular expression question


  Dear all
 
  I have a txt file like the bottom (I use cleardiff to compare 2 files
and
  get this file):
 
  I will check whether the line includes ___GENERIC_MULTILINE___ or not,
 if
  it includes, I will get the following information
 
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
 
  without  sign,
 
  How can I do it?
 
  Thanks a lot in advance!
 
  Lixin
 
  #
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  24c24,30
   ___GENERIC_MULTILINE___
  ---
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  ##
 
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


regular expression question

2003-03-28 Thread Cai_Lixin
Dear all

I have a txt file like the bottom (I use cleardiff to compare 2 files and
get this file):

I will check whether the line includes ___GENERIC_MULTILINE___ or not, if
it includes, I will get the following information

 GENERATION 116 
 # Impossible dependency 
 # Needed to prevent FC4700 to CX-series upgrades 
 DEPEND Navisphere 2.0.0.0.0 
 DEPEND Navisphere 1.0.0.0.0 
 GENDEPEND Navisphere 116 


without  sign,

How can I do it?

Thanks a lot in advance!

Lixin  

#
3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 REVISION 02041405.002 
 DISPLAYREV 02.04.1.40.5.002 
24c24,30
 ___GENERIC_MULTILINE___
---
 GENERATION 116 
 # Impossible dependency 
 # Needed to prevent FC4700 to CX-series upgrades 
 DEPEND Navisphere 2.0.0.0.0 
 DEPEND Navisphere 1.0.0.0.0 
 GENDEPEND Navisphere 116 
  
3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 REVISION 02041405.002 
 DISPLAYREV 02.04.1.40.5.002
##

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Cai_Lixin
I have another question,

I have string like  GENERATION 116, How can I get rid of , of the
string?

Thanks

Lixin



-Original Message-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 11:30 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: regular expression question


load the file into a file handle, and iterate through it line by line. Pipe
each line to the file handle (the | is not a typo in the example)...

So,

open(fHandle, myfile.txt|);
while (defined ($line = fHandle)){
if ($line ~= /generic/ig){
do something}
};

Hope this helps,

NuTs


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 9:40 AM
Subject: regular expression question


 Dear all

 I have a txt file like the bottom (I use cleardiff to compare 2 files and
 get this file):

 I will check whether the line includes ___GENERIC_MULTILINE___ or not,
if
 it includes, I will get the following information

  GENERATION 116
  # Impossible dependency
  # Needed to prevent FC4700 to CX-series upgrades
  DEPEND Navisphere 2.0.0.0.0
  DEPEND Navisphere 1.0.0.0.0
  GENDEPEND Navisphere 116
 

 without  sign,

 How can I do it?

 Thanks a lot in advance!

 Lixin

 #
 3,4c3,4
  REVISION ___INTERNAL_REV___
  DISPLAYREV ___EXTERNAL_REV___
 ---
  REVISION 02041405.002
  DISPLAYREV 02.04.1.40.5.002
 24c24,30
  ___GENERIC_MULTILINE___
 ---
  GENERATION 116
  # Impossible dependency
  # Needed to prevent FC4700 to CX-series upgrades
  DEPEND Navisphere 2.0.0.0.0
  DEPEND Navisphere 1.0.0.0.0
  GENDEPEND Navisphere 116
 
 3,4c3,4
  REVISION ___INTERNAL_REV___
  DISPLAYREV ___EXTERNAL_REV___
 ---
  REVISION 02041405.002
  DISPLAYREV 02.04.1.40.5.002
 ##

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Another regular expression question

2003-03-20 Thread Tobias Hoellrich
At 10:28 AM 3/20/2003 -0500, you wrote:
Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;

I want to get extension of the file name which is ndu, but I always get
04.1.20.5.002-xlite_katana_free.ndu instead of ndu.
The sub is like:

sub extension
{
my $path = shift;
my $ext = fileparse($path, '\..*?'))[2];
$ext =~ s/^\.//;
return $ext;
}
what is wrong with it?


I really like to use split for that task
   Tobias
my $file=Base-02.04.1.20.5.002-xlite_katana_free.ndu;
print extension for $file is ,extension($file),\n;
sub extension
{
  (split(/\./,$_[0]))[-1];
}
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Another regular expression question

2003-03-20 Thread kadir
Hi!

On 20 Mar 2003 at 10:28, [EMAIL PROTECTED] wrote:

 Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;
 
 I want to get extension of the file name which is ndu, but I always
 get 04.1.20.5.002-xlite_katana_free.ndu instead of ndu.
:

Try the code below. i think it works.

Regards,

Rodrigo


code

use strict;

sub extension
{
my $path = shift;

my @all= split(/\./, $path);


return @all  1?pop @all: undef;

}

my $fName= 'Base-02.04.1.20.5.002-xlite_katana_free.ndu';

print The extension of \$fName\ is \, extension($fName), \\n;

print Type anothe file name: ;

my $otherName= ;

chomp $otherName;

my $ext= extension($otherName);

if ( defined $ext )

 { print \$otherName\ extension is \$ext\\n; }

else

 { print \$otherName\ has no extension!!\n; }

/code

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Another regular expression question

2003-03-20 Thread Scott Purcell
You could use conventional hacking. rindex will get the last '.' and substr will 
hand back the remainder.

print  extension(Base-02.04.1.20.5.002-xlite_katana_free.ndu);
sub extension 
{
return (substr($_[0], rindex($_[0], '.')));
}

-Scott



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 9:28 AM
To: [EMAIL PROTECTED]
Subject: Another regular expression question


Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;

I want to get extension of the file name which is ndu, but I always get
04.1.20.5.002-xlite_katana_free.ndu instead of ndu.

The sub is like:

sub extension
{
my $path = shift;
my $ext = fileparse($path, '\..*?'))[2];
$ext =~ s/^\.//;
return $ext;
} 

what is wrong with it?

Thanks

Lixin
 

-Original Message-
From: Randy W. Sims [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 6:24 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: an regular expression question


On 3/19/2003 6:16 PM, [EMAIL PROTECTED] wrote:
 All,
 
 A question:
 A file like C:\temp\test.txt, how can I get test.txt from this path by
 regular expression? I can do it by split function, but I hope I can learn
 how to do it by regular expression.
 
 Thanks a lot in advance!
 
 Lixin
 

use File::Basename;
my $fullpath = 'C:\temp\test.txt';
my $basename = basename( $fullpath );

Randy.

-- 
A little learning is a dang'rous thing;
Drink deep, or taste not the Pierian spring;
There shallow draughts intoxicate the brain;
And drinking largely sobers us again.
 - Alexander Pope

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Another regular expression question

2003-03-20 Thread Carl Jolley
On Thu, 20 Mar 2003 [EMAIL PROTECTED] wrote:

 Filename = Base-02.04.1.20.5.002-xlite_katana_free.ndu;

 I want to get extension of the file name which is ndu, but I always get
 04.1.20.5.002-xlite_katana_free.ndu instead of ndu.

 The sub is like:

 sub extension
 {
   my $path = shift;
   my $ext = fileparse($path, '\..*?'))[2];
   $ext =~ s/^\.//;
   return $ext;
 }

 what is wrong with it?

 Thanks

 Lixin


 -Original Message-
 From: Randy W. Sims [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, March 19, 2003 6:24 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: an regular expression question


 On 3/19/2003 6:16 PM, [EMAIL PROTECTED] wrote:
  All,
 
  A question:
  A file like C:\temp\test.txt, how can I get test.txt from this path by
  regular expression? I can do it by split function, but I hope I can learn
  how to do it by regular expression.
 
  Thanks a lot in advance!
 
  Lixin
 

 use File::Basename;
 my $fullpath = 'C:\temp\test.txt';
 my $basename = basename( $fullpath );

 Randy.


Your best bet is to use a regex match on the extension anchored at the end
of the string. If your extension is always 3 characters, this would work:

($extension)=$path=~/\.(\w{3})$/;

If the extention can be of arbirtrary length then you could use

($extension)=$path=~/\.(\w+)$/;

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Beginner Regular Expression Question

2003-03-20 Thread Lupi, Guy
I am trying to figure out how to specify or in a regular expression.
Basically, I am specifying the Prompt portion of a telnet session using
Net::Telnet, and I want to match several possible strings that would make up
the prompts.  An explanation below:

'/br[0-9][0-9]/' or '/mar[0-9][0-9]/' or '/tr[0-9][0-9]/' or
'/ber[0-9]/'

Does anyone know if this can be done, and if so how?  Thanks.

Guy H. Lupi


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Beginner Regular Expression Question

2003-03-20 Thread C. Church
 Net::Telnet, and I want to match several possible strings that would make
up
 the prompts.  An explanation below:

 '/br[0-9][0-9]/' or '/mar[0-9][0-9]/' or '/tr[0-9][0-9]/' or
 '/ber[0-9]/'


One way is:

if($string =~ /(?:b|t|be|ma)r[0-9]{2}/) {
...
}

The operative operator (heh) here is '|'

Note, no need to repeat your character-class, tell the RE exactly what you
mean, instead.

For example:

my @strs = ('mar55','br99','tr51','ber00','for11');

foreach my $str (@strs) {

my $ma = didn't;
$ma = did if($str =~ /(?:b|t|be|ma)r[0-9]{2}/);

print(String $str $ma match the RE\n);
}

Prints the following:

C:\source\crapperl ormatch.pl
String mar55 did match the RE
String br99 did match the RE
String tr51 did match the RE
String ber00 did match the RE
String for11 didn't match the RE

!c
C. Church
http://www.digitalKOMA.com/church/
http://www.DroneColony.com/


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-14 Thread Carl Jolley
On Sun, 9 Mar 2003, Electron One wrote:

 Hello Everyone,

   If I have a file that contains this,

 test3.txt##
 wilma

 wimagren was here

 twilma was type wilma

 wilma

 wilma

 wilma

 twowilmase
 ##

 and i have a perl script that contains this,

 ###perlname.pl
 #!/usr/bin/perl


 while(){
 chomp;
 if(/wilma\s+/){
print wilma was mentioned\n;
}
 }

 #

 and I type, perl -w perlname.pl test3.txt
 shouldnt the output be, wilma was mentioned \n, 7 times? My output file
 only mentions it once. What am I doing wrong?


Two things:

One since your are chomping the input line, your regex which requires
trailing white space after 'wilma' wont't match those lines which end with
the characters wilma. I suggest you change your regex to: /wilma\b/.
Alternatively you could just take out the chomp.

Two you are only checking for one instance of your regex per input line.
I suggest you change your code from an 'if' to:

while(/wilma\b/g) {

You should get 6 matches on your input file not seven.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-10 Thread Phil Ritchie

Not if the fourth to sixth lines don't have a space before the end of line.
Try if(/wilma\s*/). Actually, you'll need to use if(/wilma/g) to catch them
all.

Phil.



|-+---
| |   Electron One|
| |   [EMAIL PROTECTED]|
| |   Sent by:|
| |   [EMAIL PROTECTED]|
| |   veState.com |
| |   |
| |   |
| |   10/03/03 02:29  |
| |   |
|-+---
  
--|
  |
  |
  |   To:   [EMAIL PROTECTED]  
  |
  |   cc:   electron One [EMAIL PROTECTED]   
 |
  |   Subject:  Regular Expression matching problem
  |
  
--|




Hello Everyone,

  If I have a file that contains this,

test3.txt##

wilma

wimagren was here

twilma was type wilma

wilma

wilma

wilma

twowilmase
##


and i have a perl script that contains this,

###perlname.pl

#!/usr/bin/perl


while(){
chomp;
if(/wilma\s+/){
   print wilma was mentioned\n;
   }
}

#


and I type, perl -w perlname.pl test3.txt
shouldnt the output be, wilma was mentioned \n, 7 times? My output file
only mentions it once. What am I doing wrong?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs







**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
www.vistatec.ie
**

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


AW: Regular Expression matching problem

2003-03-10 Thread Wittrock, Friedel
\b is the answer:

--
while (DATA) {
chomp;
if (/\bwilma\b/) {
print wilma was mentioned\n;
}
}

__DATA__
wilma
wimagren was here
twilma was type wilma
wilma
wilma
wilma
twowilmase
--
Output:

wilma was mentioned
wilma was mentioned
wilma was mentioned
wilma was mentioned
wilma was mentioned


regards
Friedel Wittrock



-Ursprungliche Nachricht-
Von: Phil Ritchie [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 10. Marz 2003 09:59
An: Electron One
Cc: [EMAIL PROTECTED]
Betreff: Re: Regular Expression matching problem



Not if the fourth to sixth lines don't have a space before the end of line.
Try if(/wilma\s*/). Actually, you'll need to use if(/wilma/g) to catch them
all.

Phil.



|-+---
| |   Electron One|
| |   [EMAIL PROTECTED]|
| |   Sent by:|
| |   [EMAIL PROTECTED]|
| |   veState.com |
| |   |
| |   |
| |   10/03/03 02:29  |
| |   |
|-+---
  
--|
  |
  |
  |   To:   [EMAIL PROTECTED]  
  |
  |   cc:   electron One [EMAIL PROTECTED]   
 |
  |   Subject:  Regular Expression matching problem
  |
  
--|




Hello Everyone,

  If I have a file that contains this,

test3.txt##

wilma

wimagren was here

twilma was type wilma

wilma

wilma

wilma

twowilmase
##


and i have a perl script that contains this,

###perlname.pl

#!/usr/bin/perl


while(){
chomp;
if(/wilma\s+/){
   print wilma was mentioned\n;
   }
}

#


and I type, perl -w perlname.pl test3.txt
shouldnt the output be, wilma was mentioned \n, 7 times? My output file
only mentions it once. What am I doing wrong?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs







**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
www.vistatec.ie
**

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Another Regular expression problem

2003-03-10 Thread Stovall, Adrian M.
 -Original Message-
 From: Electron One [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 10, 2003 12:12 PM
 To: [EMAIL PROTECTED]
 Cc: Electron One
 Subject: Another Regular expression problem
 
 
 Hello Everyone,
 
I have a perl file that has this,
 
 PerlFile.pl###
 
 #!/usr/bin/perl
 
 
 
 while(){
 chomp;
 if(/\s*\$[a-z]\w+\s*/i){
 #if(/\b\$[a-z]\w+\b/i){
 print Matched: $` -- $ -- $' :\n;
  }
 
 
 else{
print No match:$_\n;
 }
 
 } 
 ##
 ##
 
 I have another file that has this in it,
 
 testfile.txt##
 #
 $he1lo is the name of a variable
 what is not allowed $0 is this
 but this is $a123wgfd343w cool
 this is correct though $hello dont know why didnt work 
 before. I sure hope this doesnt pass alf$f12w32 cuz it 
 shouldnt $alfonso does match though $hello 
 ##
 
 
 The perl code is basically supposed to look for real possible scalar 
 variable names. So there should only be two failures,
 the second and fifth line should not pass.
 
 Now, if I run the program how it is, I get this,
 
 answer1.txt###
 ##
 
 Matched:  -- $he1lo  -- is the name of a variable :
 No match:what is not allowed $0 is this
 Matched: but this is --  $a123wgfd343w  -- cool :
 Matched: this is correct though --  $hello  -- dont know why 
 didnt work 
 before. :
 Matched: I sure hope this doesnt pass alf -- $f12w32  -- cuz 
 it shouldnt :
 Matched:  -- $alfonso  -- does match though :
 Matched:  -- $hello --  :
 No match: 
 ##
 
 if i run it with the commented section as the if statement, 
 and the current 
 if statement commented out, i get this,
 
 ###answer2.txt
 ##
 No match:$he1lo is the name of a variable
 No match:what is not allowed $0 is this
 No match:but this is $a123wgfd343w cool
 No match:this is correct though $hello dont know why didnt 
 work before.
 Matched: I sure hope this doesnt pass alf -- $f12w32 --  cuz 
 it shouldnt : No match:$alfonso does match though No 
 match:$hello No match: 
 ##
 #
 
 With regard to answer2.txt, why doesn't it match lines 
 1,3,4,5 and 6? In 
 the camel book(pg40), it says that the word bound \b matches 
 the beginning 
 of lines.
 
 Any advice would be appreciated.
 
 Thanks.
 

Beats me...I can't wait to find out the answer to this one.  $Bill,
explain it to us idiots... 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Another Regular expression problem

2003-03-10 Thread Ted Zeng
 if(/\$\b[a-z]\w+\b/i)

should work. \b only includes those chars in \w which doesn't include
$. So $ is not include in the word, only hello is included.

ted zeng

Stovall, Adrian M. wrote:

  -Original Message-
  From: Electron One [mailto:[EMAIL PROTECTED]
  Sent: Monday, March 10, 2003 12:12 PM
  To: [EMAIL PROTECTED]
  Cc: Electron One
  Subject: Another Regular expression problem
 
 
  Hello Everyone,
 
 I have a perl file that has this,
 
  PerlFile.pl###
  
  #!/usr/bin/perl
 
 
 
  while(){
  chomp;
  if(/\s*\$[a-z]\w+\s*/i){
  #if(/\b\$[a-z]\w+\b/i){
  print Matched: $` -- $ -- $' :\n;
   }
 
 
  else{
 print No match:$_\n;
  }
 
  }
  ##
  ##
 
  I have another file that has this in it,
 
  testfile.txt##
  #
  $he1lo is the name of a variable
  what is not allowed $0 is this
  but this is $a123wgfd343w cool
  this is correct though $hello dont know why didnt work
  before. I sure hope this doesnt pass alf$f12w32 cuz it
  shouldnt $alfonso does match though $hello
  ##
  
 
  The perl code is basically supposed to look for real possible scalar
  variable names. So there should only be two failures,
  the second and fifth line should not pass.
 
  Now, if I run the program how it is, I get this,
 
  answer1.txt###
  ##
 
  Matched:  -- $he1lo  -- is the name of a variable :
  No match:what is not allowed $0 is this
  Matched: but this is --  $a123wgfd343w  -- cool :
  Matched: this is correct though --  $hello  -- dont know why
  didnt work
  before. :
  Matched: I sure hope this doesnt pass alf -- $f12w32  -- cuz
  it shouldnt :
  Matched:  -- $alfonso  -- does match though :
  Matched:  -- $hello --  :
  No match:
  ##
  
  if i run it with the commented section as the if statement,
  and the current
  if statement commented out, i get this,
 
  ###answer2.txt
  ##
  No match:$he1lo is the name of a variable
  No match:what is not allowed $0 is this
  No match:but this is $a123wgfd343w cool
  No match:this is correct though $hello dont know why didnt
  work before.
  Matched: I sure hope this doesnt pass alf -- $f12w32 --  cuz
  it shouldnt : No match:$alfonso does match though No
  match:$hello No match:
  ##
  #
 
  With regard to answer2.txt, why doesn't it match lines
  1,3,4,5 and 6? In
  the camel book(pg40), it says that the word bound \b matches
  the beginning
  of lines.
 
  Any advice would be appreciated.
 
  Thanks.
 

 Beats me...I can't wait to find out the answer to this one.  $Bill,
 explain it to us idiots...
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Another Regular expression problem

2003-03-10 Thread Electron One
At 12:06 PM 3/10/2003 -0800, Ted Zeng wrote:
 if(/\$\b[a-z]\w+\b/i)

should work.
If i do this, it will still include this line,

I sure hope this doesnt pass alf$f12w32  cuz it shouldnt

And I want it to be a word that starts off with the $ symbol. :-(


 \b only includes those chars in \w which doesn't include
$. So $ is not include in the word, only hello is included.
Can you explain this a little further, I dont understand you very well.

Thanks very much.



ted zeng

Stovall, Adrian M. wrote:

  -Original Message-
  From: Electron One [mailto:[EMAIL PROTECTED]
  Sent: Monday, March 10, 2003 12:12 PM
  To: [EMAIL PROTECTED]
  Cc: Electron One
  Subject: Another Regular expression problem
 
 
  Hello Everyone,
 
 I have a perl file that has this,
 
  PerlFile.pl###
  
  #!/usr/bin/perl
 
 
 
  while(){
  chomp;
  if(/\s*\$[a-z]\w+\s*/i){
  #if(/\b\$[a-z]\w+\b/i){
  print Matched: $` -- $ -- $' :\n;
   }
 
 
  else{
 print No match:$_\n;
  }
 
  }
  ##
  ##
 
  I have another file that has this in it,
 
  testfile.txt##
  #
  $he1lo is the name of a variable
  what is not allowed $0 is this
  but this is $a123wgfd343w cool
  this is correct though $hello dont know why didnt work
  before. I sure hope this doesnt pass alf$f12w32 cuz it
  shouldnt $alfonso does match though $hello
  ##
  
 
  The perl code is basically supposed to look for real possible scalar
  variable names. So there should only be two failures,
  the second and fifth line should not pass.
 
  Now, if I run the program how it is, I get this,
 
  answer1.txt###
  ##
 
  Matched:  -- $he1lo  -- is the name of a variable :
  No match:what is not allowed $0 is this
  Matched: but this is --  $a123wgfd343w  -- cool :
  Matched: this is correct though --  $hello  -- dont know why
  didnt work
  before. :
  Matched: I sure hope this doesnt pass alf -- $f12w32  -- cuz
  it shouldnt :
  Matched:  -- $alfonso  -- does match though :
  Matched:  -- $hello --  :
  No match:
  ##
  
  if i run it with the commented section as the if statement,
  and the current
  if statement commented out, i get this,
 
  ###answer2.txt
  ##
  No match:$he1lo is the name of a variable
  No match:what is not allowed $0 is this
  No match:but this is $a123wgfd343w cool
  No match:this is correct though $hello dont know why didnt
  work before.
  Matched: I sure hope this doesnt pass alf -- $f12w32 --  cuz
  it shouldnt : No match:$alfonso does match though No
  match:$hello No match:
  ##
  #
 
  With regard to answer2.txt, why doesn't it match lines
  1,3,4,5 and 6? In
  the camel book(pg40), it says that the word bound \b matches
  the beginning
  of lines.
 
  Any advice would be appreciated.
 
  Thanks.
 

 Beats me...I can't wait to find out the answer to this one.  $Bill,
 explain it to us idiots...
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Another Regular expression problem

2003-03-10 Thread Joseph P. Discenza
Electron One wrote, on Monday, March 10, 2003 13:12
: while(){
: chomp;
: if(/\s*\$[a-z]\w+\s*/i){
: #if(/\b\$[a-z]\w+\b/i){
: print Matched: $` -- $ -- $' :\n;
:  }
: else{
:print No match:$_\n;
: }
: }
: 
: testfile.txt##
: $he1lo is the name of a variable
: what is not allowed $0 is this
: but this is $a123wgfd343w cool
: this is correct though $hello dont know why didnt work before.
: I sure hope this doesnt pass alf$f12w32 cuz it shouldnt
: $alfonso does match though
: $hello
: ##
: 
: Now, if I run the program how it is, I get this,
: 
: Matched:  -- $he1lo  -- is the name of a variable :
: No match:what is not allowed $0 is this
: Matched: but this is --  $a123wgfd343w  -- cool :
: Matched: this is correct though --  $hello  -- dont know why didnt work 
: before. :
: Matched: I sure hope this doesnt pass alf -- $f12w32  -- cuz it shouldnt :
: Matched:  -- $alfonso  -- does match though :
: Matched:  -- $hello --  :
: No match:

: if i run it with the commented section as the if statement, and 
: the current 
: if statement commented out, i get this,
: 
: No match:$he1lo is the name of a variable
: No match:what is not allowed $0 is this
: No match:but this is $a123wgfd343w cool
: No match:this is correct though $hello dont know why didnt work before.
: Matched: I sure hope this doesnt pass alf -- $f12w32 --  cuz it shouldnt :
: No match:$alfonso does match though
: No match:$hello
: 
: Why doesn't the second match lines 1,3,4,5 and 6? In 
: the camel book(pg40), it says that the word bound \b matches the 
: beginning of lines.

The \b word boundary marks a boundary between a \w character and either
a \W character or one end of the line. I think what you really want is
this:

/(^|\W)\$[a-zA-Z]\w*\b/

Since $ is not a word character, you *do* get a word boundary when the $
appears in the middle of a word (hence your match on alf$f12w32 and nowhere
else). What you really want is to have the $ preceded by either the beginning
of the line or a non-word character. I also bet you *do* want to allow one-
character variables? If not, change the * back to a +.

Good luck,

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! * 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular Expression matching problem

2003-03-09 Thread Electron One
Hello Everyone,

 If I have a file that contains this,

test3.txt##
wilma
wimagren was here

twilma was type wilma

wilma

wilma

wilma

twowilmase
##
and i have a perl script that contains this,

###perlname.pl
#!/usr/bin/perl
while(){
   chomp;
   if(/wilma\s+/){
  print wilma was mentioned\n;
  }
   }
#

and I type, perl -w perlname.pl test3.txt
shouldnt the output be, wilma was mentioned \n, 7 times? My output file 
only mentions it once. What am I doing wrong?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-09 Thread Keith C. Ivey
Electron One [EMAIL PROTECTED] wrote:

 while(){
 chomp;
 if(/wilma\s+/){
print wilma was mentioned\n;
}
 }
 
 #
 
 and I type, perl -w perlname.pl test3.txt
 shouldnt the output be, wilma was mentioned \n, 7 times? My
 output file only mentions it once. What am I doing wrong?

What do you think the '\s+' means in that regular expression?  
After you've chomped them, only one line has whitespace after 
'wilma', so only one matches.

-- 
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Regular expression question

2002-12-12 Thread Mangesh



I want to translate some chaarctersin a 
string to its replacement string.

I am doing this.
#**
$inchar = 
"\xa2\xa3";$outchar = "\[Cent]\[Pound]";
eval "\$buf =~ tr/$inchar/$outchar/";

#$buf =~ s/$inchar/$outchar/;
print "$buf \n";
#**

This is not working. Please Help.

Thanks,
-Mangesh


Re: regular expression question

2002-11-23 Thread Carl Jolley
On Fri, 22 Nov 2002 [EMAIL PROTECTED] wrote:

 all,

 I want to check the first line of the file if it is machine or not, like

 The first line of the file is:

 Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.

 my code is like:

 if (!-z $file)
 {
 open(LOG_FILE, $file) or warn  can not open $file:$!\n;
 my @read_lines = LOG_FILE;
 close (LOG_FILE);
 next unless chomp($read_lines[0]) =~ m#\\nest and \toolbox VOBs\#;
 }

 it did not work for regular expression, can you help me to figure what is
 wrong with it?


You are performing your regex match on the result of the function call:
chomp($read_lines[0]). The value of chomp will be 1 if it removed a
new-line character from the end of $read_lines[0] and it will be zero if
it didn't remove a new-line character, i.e. if the last character was not
the new-line character (actually the $/ string which has a default value
of \n).  Somehow I don't believe that your regex will match either a 1
or a 0.

However, even if you anchor the regex on the variable $read_lines[0],
I don't believe that the regex match string is correct considering
that fact that it contains the representation of a new-line character (the
\n) and a tab (the \t). Also note that it is not necessary to escape the
double quote characters inside the regex match string unless the quote is
used to delimit the match string (you used # to delimit the regex match
string, my code below uses the default regex delimter, /) I believe the
the following will fix your problem as far as the regex is concerned:

next unless $read_lines[0] =~ /\\nest and \\toolbox VOBs/;

Take out the chomp, it serves no purpose based on the code fragment
you showed. Also reconsider your logic. Exactly what do you expect to
happen if the regex doesn't match, i.e. if the 'next' is done what
code will then execute next?

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-23 Thread Carl Jolley
On Fri, 22 Nov 2002, Stovall, Adrian M. wrote:

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Friday, November 22, 2002 4:38 PM
  To: Stovall, Adrian M.; [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: regular expression question
 
 
  I tried that, it does not work for me!
 
  Lixin
 

 This code should print yes, if it does, then the code works for you...

 $line = 'Job \nest and \toolbox VOBs began execution on 9/6/02 at
 2:00:11 AM.';
 print $line\n;
 if ($line =~ m#\\\nest and \\toolbox VOBs\#) { print yes; }
 else { print no; }


Your code may work fine but as long as his code is archoring
the regex to the result of the function call: chomp($read_lines[0])
it won't. Unless of course he changes the regex match string to:

m#^[01]$#;

Note that the result of doing chomp on a scalar will be one of
two values, 0 or 1.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



regular expression question

2002-11-22 Thread Cai_Lixin
all,

I want to check the first line of the file if it is machine or not, like

The first line of the file is:

Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.

my code is like:

if (!-z $file)
{
open(LOG_FILE, $file) or warn  can not open $file:$!\n;
my @read_lines = LOG_FILE;
close (LOG_FILE);
next unless chomp($read_lines[0]) =~ m#\\nest and \toolbox VOBs\#;
}

it did not work for regular expression, can you help me to figure what is
wrong with it?

Thanks a lot!

Lixin
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Cai_Lixin
Sorry, I did not state quite clear, if it is machine or not, I want to say
if I it is the right file or not...

Lixin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:07 PM
Cc: [EMAIL PROTECTED]
Subject: regular expression question


all,

I want to check the first line of the file if it is machine or not, like

The first line of the file is:

Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.

my code is like:

if (!-z $file)
{
open(LOG_FILE, $file) or warn  can not open $file:$!\n;
my @read_lines = LOG_FILE;
close (LOG_FILE);
next unless chomp($read_lines[0]) =~ m#\\nest and \toolbox VOBs\#;
}

it did not work for regular expression, can you help me to figure what is
wrong with it?

Thanks a lot!

Lixin
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Stovall, Adrian M.
Cai Lixin said:
 
 
 all,
 
 I want to check the first line of the file if it is machine 
 or not, like
 
 The first line of the file is:
 
 Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
 
 my code is like:
 
 if (!-z $file)
 {
 open(LOG_FILE, $file) or warn  can not open $file:$!\n;
 my @read_lines = LOG_FILE;
 close (LOG_FILE);
 next unless chomp($read_lines[0]) =~ m#\\nest and 
 \toolbox VOBs\#;
 }
 
 it did not work for regular expression, can you help me to 
 figure what is wrong with it?
 

You forgot to escape the backslashes...change your code to read:

next unless chomp($read_lines[0]) =~ m#\\\nest and \\toolbox VOBs\#) 



perl -e sub Sub{return reverse(@_);}$_='.$yyye k ca i Xl $yyye jX $yyye
hto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);$print=join('',Sub(split('')));system(
'echo',$print);

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian Okay, I won't top-post unless it's an emergency Stovall
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



  1   2   >