Forum Discussion
John_Heyer_1508
Cirrostratus
Apr 20, 2017Using String Match to Check if all Numbers
Basically I'm looking to test if a string is 10 digits and all numbers. Matching the 10 digits works, but not having any luck verifying if all numbers. This is the code I'm trying to use: set S...
- Apr 20, 2017
Try this:
when ACCESS_ACL_ALLOWED { set STRING "1234567890" if { [string length $STRING] == 10 && [string is digit $STRING ] == 1 } { log local0. "The string is 10 digits" } else { log local0. "The string is not 10 digits" } }
Jason0_309417
Cirrus
Apr 20, 2017Try this:
when ACCESS_ACL_ALLOWED {
set STRING "1234567890"
if { [string length $STRING] == 10 && [string is digit $STRING ] == 1 } {
log local0. "The string is 10 digits"
} else {
log local0. "The string is not 10 digits"
}
}
- John_Heyer_1508Apr 20, 2017
Cirrostratus
Thanks! "is digit" is the shortcut I was looking for. I had been trying "string is integer", but in order for that to work I would have had to type it to int first, which seemed like an unnecessary step.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects