How to check if the value is alphanumeric or not

I am getting output values after some processing. these values are something like.

AG9C9D91
12335666
TESTTEST
Test/-123*
5879-7888
Test_testp

I want verify if values are alphanumeric or not.
Is there like Isalnum option available or anyother workaround ?

Thanks!

  ${res}     Evaluate    "${your_variable}".isalnum() 
2 Likes

Thanks but it is not working. For any value the result is returning as true.

If all those above are returning True then it might be worth sharing your code, as the return should be True or False if you pass each output value to the above-statement @rasjani has provided. just for further context, the isalnum() method returns True if all the characters are alphanumeric (a-z)(0-9) and False if they are not alphanumeric (space)!#%&? etc.

So in your example, Test*/-123* should return False as it is not alphanumeric, and AG9C9D91 should return True

Here’s a working example:

*** Test Cases ***
Alphanumeric Or Not - Example
     @{output_list}=    Create List     AG9C9D91   12335666   TESTTEST   Test/-123*   5879-7888   Test_testp
     Log To Console        \n
     FOR    ${item}    IN    @{output_list}
         ${res}=     Evaluate    "${item}".isalnum() 
         Log To Console    Is Item:${item} Alphanumeric: ${res}        
     END

1 Like