473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Need help with REGEX

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

Oct 23 '08 #1
1 1563
-----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-----
Oct 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joe | last post by:
Hi, I have been using a regular expression that I don’t uite understand to filter the valid email address. My regular expression is as follows: <asp:RegularExpressionValidator...
2
by: Luhar | last post by:
After much scouring of information on Regular Expressions from books and the web, I've come up with the this handy little Regex to parse links from HTML: ...
2
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a...
1
by: hillcountry74 | last post by:
Hi, I'm stuck with this regular expression from past 2 days. Desperately need help. I need a regular expression that will allow all characters except these *:~<>' This is my code in...
9
by: jmchadha | last post by:
I have got the following html: "something in html ... etc.. city1... etc... <a class="font1" href="city1.html" onclick="etc."click for <b>info</bon city1 </a> ... some html. city1.. can repeat...
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
I'm trying to learn regex but since I've spent way too much time on the following "simple" case, there's obviously something I'm missing. I need to find all occurrences of a specific...
8
by: Alexander Vasilevsky | last post by:
This code Regex ge = new Regex(""); string format = ge.Replace("8 kBit/s, 8,000 Hz, Mono", "_"); returns "8 kBit_s_ 8_000 Hz_ Mono" and I need "8_kBit_s_ 8_000_Hz_ Mono"
4
by: Danny Ni | last post by:
Hi, The following code snippet is causing CPU to max out on my local machine and production servers. It looks fine on Expresso though. Regex rgxVideo = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.