Skip to main content
deleted 91 characters in body
Source Link
alper
  • 8.4k
  • 11
  • 67
  • 155

Just cast the string to bytes

   function testStr(string str) constant returns (bool){
        bytes memory b = bytes(str);
        if(b.length != 7) return false;
        for(uint i; i<7; i++){
            if(i==1){
                if(b[i] != 45) return false;
            }
            else if (i==4){
                if(b[i] != 58) return false;
            }
            else if(b[i] < 48 || b[i] > 57) return false;
            
        }
    
        return true;
    }
function testStr(string str) constant returns (bool) {
    bytes memory b = bytes(str);
    if (b.length != 7)
        return false;
    for (uint i; i < 7; i++) {
        if (i==1) {
            if(b[i] != 45) return false;
        }
        else if (i == ) {
            if(b[i] != 58) return false;
        }
        else if(b[i] < 48 || b[i] > 57)
            return false;
    }
    return true;
}

Just cast the string to bytes

   function testStr(string str) constant returns (bool){
        bytes memory b = bytes(str);
        if(b.length != 7) return false;
        for(uint i; i<7; i++){
            if(i==1){
                if(b[i] != 45) return false;
            }
            else if (i==4){
                if(b[i] != 58) return false;
            }
            else if(b[i] < 48 || b[i] > 57) return false;
            
        }
    
        return true;
    }

Just cast the string to bytes

function testStr(string str) constant returns (bool) {
    bytes memory b = bytes(str);
    if (b.length != 7)
        return false;
    for (uint i; i < 7; i++) {
        if (i==1) {
            if(b[i] != 45) return false;
        }
        else if (i == ) {
            if(b[i] != 58) return false;
        }
        else if(b[i] < 48 || b[i] > 57)
            return false;
    }
    return true;
}
Source Link
Tjaden Hess
  • 37.3k
  • 11
  • 91
  • 118

Just cast the string to bytes

   function testStr(string str) constant returns (bool){
        bytes memory b = bytes(str);
        if(b.length != 7) return false;
        for(uint i; i<7; i++){
            if(i==1){
                if(b[i] != 45) return false;
            }
            else if (i==4){
                if(b[i] != 58) return false;
            }
            else if(b[i] < 48 || b[i] > 57) return false;
            
        }
    
        return true;
    }