Re: Need help with REGEX

Discussion in 'Perl' started by Pedro Silva, Oct 27, 2008.

  1. Pedro Silva

    Pedro Silva Guest

    -----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

    iEYEARECAAYFAkkFbLcACgkQvUI03qKHSRrbmwCeMi8HJg0gXSgDQsshLi9+uzR/
    pcUAn1f0t7pWubhjjO2ALUSyJUW7xX8E
    =rCw7
    -----END PGP SIGNATURE-----
     
    Pedro Silva, Oct 27, 2008
    #1
    1. Advertisements

  2. Pedro Silva

    philyeagle

    Joined:
    Oct 31, 2008
    Messages:
    1
    Likes Received:
    0
    hello

    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
     
    philyeagle, Oct 31, 2008
    #2
    1. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Shapper

    Validate Email. RegEx. Need Help.

    Shapper, May 11, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,051
    Brock Allen
    May 11, 2005
  2. Christophe Vanfleteren

    Need help with regex

    Christophe Vanfleteren, May 2, 2004, in forum: Java
    Replies:
    6
    Views:
    453
    Christophe Vanfleteren
    May 3, 2004
  3. -

    need help with regex

    -, Feb 8, 2005, in forum: Java
    Replies:
    7
    Views:
    500
    Alan Moore
    Feb 10, 2005
  4. DartmanX

    Need Help With Java Regex

    DartmanX, Jun 9, 2005, in forum: Java
    Replies:
    3
    Views:
    498
    Harald
    Jun 12, 2005
  5. vamp4l

    need help with regex

    vamp4l, Nov 4, 2005, in forum: Java
    Replies:
    2
    Views:
    379
    Roedy Green
    Nov 5, 2005
  6. =?Utf-8?B?QVZM?=

    need help on regex

    =?Utf-8?B?QVZM?=, Sep 17, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    442
    Jesse Houwing
    Sep 17, 2007
  7. CodeGrommet

    Need help with regex please

    CodeGrommet, Jan 2, 2008, in forum: Java
    Replies:
    4
    Views:
    380
    Jeff Higgins
    Jan 2, 2008
  8. Replies:
    3
    Views:
    1,198
    Reedick, Andrew
    Jul 1, 2008
Loading...