Can this java function be optimized?

public static NAME_1 slugify(NAME_1 text) {

        if (text == null) {
            return null;
        }

        text = text.toLowerCase();

        StringBuilder result = new StringBuilder();

        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);

            if (Character.isLetterOrDigit(c)) {
                result.append(c);
            } else {
                result.append('-');
            }
        }
        
        // Remove double dashes
        while (result.indexOf("--") > -1) {
            result = new StringBuilder(result.toString().replace("--", "-"));
        }
        
        // Remove leading dashes
        while (result.length() > 0 && result.charAt(0) == '-') {
            result = new StringBuilder(result.substring(1));
        }
        
        // Remove trailing dashes
        while (result.length() > 0 && result.charAt(result.length() - 1) == '-') {
            result = new StringBuilder(result.substring(0, result.length() - 1));
        }

        return result.toString();
    }