You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function isAlphanumeric(stringmemorystr) publicpurereturns (bool) {
bytesmemory b =bytes(str); // Convert string to bytes for low-level handlinguint256 len = b.length; // Store length of string// Inline assembly for direct memory access and reduced gas costassembly {
// Loop over the string, byte by bytefor { let i :=0 } lt(i, len) { i :=add(i, 1) } {
let char :=byte(0, mload(add(add(b, 0x20), i))) // Load the i-th byte of string// Check if the character is not alphanumericifor(
or(
lt(char, 0x30), // Less than '0'and(gt(char, 0x39), lt(char, 0x41)) // Greater than '9' and less than 'A'
),
or(
gt(char, 0x5A), // Greater than 'Z'and(lt(char, 0x61), gt(char, 0x7A)) // Less than 'a' or greater than 'z'
)
) {
// If any character is not alphanumeric, return falsemstore(0x00, 0)
return(0x00, 0x20)
}
}
}
// If all characters are alphanumeric, return truereturntrue;
}
to avoid characters like
_
(which is meaningful in MUD protocol)The text was updated successfully, but these errors were encountered: