Re: Need help with REGEX

Discussion in 'Perl' started by Andrew Holme, Nov 30, 2008.

  1. Andrew Holme

    Andrew Holme Guest

    "Michael R. McPherson Pierotti" <> wrote in
    message news:...
    > 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
    >



    if ($line =~ /TREE=\s*(\d+)/) {

    $digits = $1;
    }
    Andrew Holme, Nov 30, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    688
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,604
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    589
  4. Xah Lee
    Replies:
    1
    Views:
    927
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    725
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page