Forum Discussion
John_Heyer_1508
Apr 20, 2017Cirrostratus
Using 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
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"
}
}
John_Heyer_1508
Apr 20, 2017Cirrostratus
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.
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