CS agents will respond to tickets via forum instead of private helpdesk to support other users with similar issues.

Check AplhaNumeric Inputs

How do I confirm if an input is AplhaNumeric or only numbers or only chars ?

Comments

  • Use String.matches() method.

    if(param.matches("^[a-zA-Z]+\$")) {
        println "only chars"
    }
    else if(param.matches("^[0-9]+\$")) {
        println "only numbers"
    }
    else if(param.matches("^[0-9a-zA-Z]+\$")) {
        println "alphanumeric"
    }
    
  • Thanks a lot.... You have saved my day :smiley:

Sign In or Register to comment.