void main(){}

char[] ctfe_lower(char[] s){
        char[] res      ;
        foreach(int i, c;s){
                if( c >= 'A' && c <='Z' ){
                        res     ~= c + 32 ;
                }else{
                        res     ~= c;
                }
        }
        return res;
}

char[] ctfe_remove(char[] _if, char[] remove){
        _if             = ctfe_lower(_if.dup);
        char[] limit    = ctfe_lower(remove.dup);
        int len = limit.length;
        char[] _if2     = null;
        foreach(int i, c; _if){
                if( _if.length - i > len ){
                        if( _if[i..i+len] == limit ){
                                if( _if[i+len] is ' ' ){
                                        _if2    = _if[0..i].dup;
                                        break;
                                }
                        }
                }
        }
        if( _if2 is null ){
                _if2    = _if.dup;
        }
        return _if2;
}

pragma(msg, ctfe_remove("1234 5", "34") );

Reply via email to