Java - Write code to Removes all punctuation Symbols of a given String.

Requirements

Write code to Removes all punctuation Symbols of a given String.

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String input = "book2s.com";
        System.out.println(removePunctuation(input));
    }/*w  w w  .ja v a2  s  .c  o m*/

    /**
     * Removes all punctuation Symbols of a given String.<br>
     * 
     * @author DirkK
     */
    public static String removePunctuation(String input) {
        input = input.replace("\t", "");
        input = input.replace("\"", "");
        input = input.replace("'", "");
        input = input.replace(".", "");
        input = input.replace(",", "");
        input = input.replace(";", "");
        input = input.replace(":", "");
        input = input.replace("(", "");
        input = input.replace(")", "");
        input = input.replace("[", "");
        input = input.replace("]", "");
        input = input.replace("/", "");
        input = input.replace("\\", "");
        input = input.replace("?", "");
        input = input.replace("!", "");
        return input;
    }
}

Related Exercise