Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

Cisco Employee

How to ensure a variable's character length

Hi,

I am using the divide function and I've found that if the remainder starts with a zero the leading zero is dropped. In my script I want to check if the output of $remainder is 6 characters and if not to add a leading zero, any idea of the best way to do this? I was thinking a regex?

Ryan

3 REPLIES
Cisco Employee

How to ensure a variable's character length

You can use the string length action for this.

string length $remainder

if $_string_result lt 6

set remainder "0$remainder"

end

Cisco Employee

How to ensure a variable's character length

Great answer, I didn't know you could do that.

What version of EEM is required for the string length command?

Cisco Employee

How to ensure a variable's character length

EEM 3.0.

398
Views
0
Helpful
3
Replies