Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Re: Need help with REGEX

Reply
Thread Tools

Re: Need help with REGEX

 
 
Pedro Silva
Guest
Posts: n/a
 
      10-27-2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm sure there's a better way of doing this:

$v="TREE= 950 ATYPE=N TON=INT ";

$v=~m/(\d)(\d)(\d)/;

$s=$1 . $2 . $3;

Pedro

Michael R. McPherson Pierotti wrote:
> Folks its been awhile (5 years) since I have done anything with Perl so I
> consider myself back at newbie statis
>
>
> #strict on
>
> use Net::Telnet ();
>
> $t = new Net::Telnet (Timeout => 10,Prompt => '/\</' ); #
>
> $t->open(Host => "X.X.X.X");
>
> $t->waitfor('/ENTER USERNAME \</');
> $t->print("XXXXXXX");
> $t->waitfor('/ENTER PASSWORD \</');
> $t->print("XXXXXXX");
> $t->waitfor('/\</')
> or die "No Prompt";
>
> @out1 = $t->get;
>
> # -------------- #
> # Dump all trees #
> # -------------- #
>
> @RIR = $t->cmd(String => "ZRIR:;", Output_record_separator => "\n") or die
> "EEEK";
> print @RIR;
>
> $n=0;
> while ($RIR[$n]) {
> if ($RIR[$n] =~ m/^TREE/){
> $line = $RIR[$n];
> $line =~ /\d/;
> print $line . "\n";
> }
> $n++;
> }
>
>
> Now my problem is this. The Net::Telnet command fills my array with lines
> like the following
>
> TREE= 950 ATYPE=N TON=INT
> DIGITS AL NBR RT CT SP NL RC DEST CHI CNT
> SDEST
> 1 0 1011 SPR NGC 11 32 APR 335 2 N 31
>
> ATYPE=N TON=NAT
> DIGITS AL NBR RT CT SP NL RC DEST CHI CNT
> SDEST
> 671456 0 900 SPR SC 1 32 APR 336 2 N 33
>
> ATYPE=N TON=NAT
> DIGITS AL NBR RT CT SP NL RC DEST CHI CNT
> SDEST
> 671476 0 900 SPR SC 1 32 APR 336 2 N 33
>
> My code if ($RIR[$n] =~ m/^TREE/) is successfully REGEX for my "TREE= 950
> ATYPE=N TON=INT "
>
> Now want I want to do is a REGEX to pull ONLY the digits out of this (950)
> and assign them to s $string. Obviosly my $line =~ /\d/; isn't working
> and
> I am braindead on REGEX since it has been so long.
>
> Any and all help is greatly appricited.
>
> BR Mike
>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkFbLcACgkQvUI03qKHSRrbmwCeMi8HJg0gXS gDQsshLi9+uzR/
pcUAn1f0t7pWubhjjO2ALUSyJUW7xX8E
=rCw7
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
 
philyeagle philyeagle is offline
Junior Member
Join Date: Oct 2008
Posts: 1
 
      10-31-2008
i'am sorry guys but i need to sent a message to one of the members
he posted a review last year and just found it today all need is to send him or her a question that they posted last year the user name is dvdlibra about pioneer 533h dvr that they repalced the hard drive if some can send me a message i will greatly appriciated i love this dvr i do want to fix it.


thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
String Pattern Matching: regex and Python regex documentation Xah Lee Java 1 09-22-2006 07:11 PM
Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine? =?Utf-8?B?SmViQnVzaGVsbA==?= ASP .Net 2 10-22-2005 02:43 PM
Java regex imposture re: Perl regex compatibility a_c_Attlee@yahoo.com Java 2 05-06-2005 12:16 AM
perl regex to java regex Rick Venter Java 5 11-06-2003 10:55 AM



Advertisments