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 STRING "1234567890"
if { [string length $STRING] == 10 && [string match {^[0-9]*} $STRING ] } {
log "The string is 10 digits"
}
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" } }