Forum Discussion

John_Heyer_1508's avatar
John_Heyer_1508
Icon for Cirrostratus rankCirrostratus
Apr 20, 2017

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...
  • Jason0_309417's avatar
    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"
             }
        }