if you are going to fap at least do it with style

owly

闇の伝説
Staff member
戦闘 コーダー
Java:
public static String negate(String sentence) {
        // Remove leading/trailing spaces and convert to lowercase
        String trimmedSentence = sentence.trim().toLowerCase();

        // Check if the sentence contains "not"
        if (trimmedSentence.contains("not")) {
            // Remove "not" and trim again
            trimmedSentence = trimmedSentence.replace("not", "").trim();
        } else {
            // Regular expression to find the first word
            String firstWord = trimmedSentence.split("\\s+")[0];

            // Prepend "not" to the first word
            trimmedSentence = "Not " + firstWord + sentence.substring(firstWord.length());
        }

        // Capitalize the first letter and return the modified sentence
        return trimmedSentence.substring(0, 1).toUpperCase() + trimmedSentence.substring(1);
    }
 

fukurou

the supreme coder
ADMIN
Java:
public static String negate(String sentence) {
        // Check if the sentence contains "not"
        String result = sentence;
        if (sentence.contains("not")) {
            result = sentence.replace("not", "");
        } else {
            result = result.replace("i ", "i do ");
            result = result.replace("he ", "he does ");
            result = result.replace(" it ", " it does ");
            result = result.replace("is", "is not");
            result = result.replace(" am", " am not");
            result = result.replace(" are", " are not");
            result = result.replace("does", "does not");
            result = result.replace("do ", "do not ");
            result = result.replace("may", "may not");
            result = result.replace("might", "might not");
            result = result.replace("could", "could not");
            result = result.replace("would", "would not");
            result = result.replace("will", "will not");
            result = result.replace("has ", "has not ");
            result = result.replace("have ", "have not ");
        }
        return result;
    }
 
Top