cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2310
Views
0
Helpful
3
Replies

How to select part of a string?

rychaney
Cisco Employee
Cisco Employee

Hi,

I have the following string from a cli command output:

630860 packets input, 624821204 bytes, 0 no buffer

I want to select the number of bytes which is of a variable length. Is there a way to do this with the action string commands? I couldn't get this to work for me.

Kind regards,

Ryan

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

Use regexp:

regexp "([0-9]+) bytes" $string match bytes

puts "Bytes is $bytes"

View solution in original post

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

Use regexp:

regexp "([0-9]+) bytes" $string match bytes

puts "Bytes is $bytes"

Ok this works.

What do the ( ) brackets indicate? I had tried a similar string in the past but I didn't have these brackets.

Ryan

They indicate that you want to extract a sub-match, in this case the number of bytes.