Description

Analyze if a char is alphanumeric (that is a letter or a number). Returns true if the input char contains either a number or a letter.

Syntax

Use the following function to evaluate a char variable:

isAlphaNumeric(thisChar)

Parameters

The function admits the following parameter:

thisChar: char variable to evaluate. Allowed data types: char.

Returns

The function returns true if the evaluated input variable is alphanumeric.

Example Code

char myChar = '3'; // try with '#' for a non alphanumeric char 

void setup() {
  Serial.begin(9600);

  if (isAlphaNumeric(myChar)) {  // tests if myChar is a letter or a number
    Serial.println("The character is alphanumeric");
  } else {
    Serial.println("The character is not alphanumeric");
  }
}

void loop() {
}

See also