Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex not working 1

Status
Not open for further replies.

netman4u

Technical User
Joined
Mar 16, 2005
Messages
176
Location
US
Hello all,

For all you regex gurus out there. I have the following text file:

Code:
send packet rate   : 1.17               send bit rate      : 1396.57           
recv packet rate   : 1.85               recv bit rate      : 3204.79

I need to get "send packet rate" as $1 and the number after the ":" as $2. as in:

$1 = send packet rate
$2 = 1.17

I do not need the send bit rate or received bit rate.

Tried many iterations. Here is where I am and it seems it should work:

Code:
	/^(.*?)\:([0-9]*\.[0-9]*)/;
	$hash{$1} = $2;

Any help is appriciated.

Nick

If at first you don't succeed, don't try skydiving.
 
You have some whitespace before and after the colon, so how about:
[tt]
/^(.*?)\s*:\s*([0-9]*\.[0-9]*)/
[/tt]
 
Thanks TonyGroves that did it! I was so close yet so far! :-).

If at first you don't succeed, don't try skydiving.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top