What is best practice in solidity for testing that an input string contains only alpha numeric characters and is not longer then x amount of chars?
function testStr(string str) constant returns (bool){
bytes memory b = bytes(str);
if(b.length > 13) return false;
for(uint i; i < b.length; i++){
//test if is tring only contains 1234567890abcdefghijklmnopqrstuvwxyz and . char
}
return true;
}
Best Answer
You can use the ASCII codes to do so: