Java String Sanitize sanitize(String input, String prohibitedStringsRegexp)

Here you can find the source of sanitize(String input, String prohibitedStringsRegexp)

Description

sanitize

License

Apache License

Declaration

public static String sanitize(String input,
            String prohibitedStringsRegexp) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final String PROHIBITED_STRINGS_REGEXP = "/|##|@|\"";
    private static final String REPLACEMENT_STRING = "_";

    /**/*from w ww.j ava 2s. c om*/
     * Sanitisation has to be used for every filename and other strings to be able to be stored correctly in the database
     * @param input
     * @return
     */
    public static String sanitize(String input) {
        return sanitize(input, PROHIBITED_STRINGS_REGEXP);
    }

    public static String sanitize(String input,
            String prohibitedStringsRegexp) {
        return sanitize(input, prohibitedStringsRegexp, REPLACEMENT_STRING);
    }

    public static String sanitize(String input,
            String prohibitedStringsRegexp, String replacement) {
        String s = input.replaceAll(prohibitedStringsRegexp,
                REPLACEMENT_STRING);
        return s;
    }
}

Related

  1. sanitize(final String name)
  2. sanitize(final String s)
  3. sanitize(final String singleOctets, byte[] dest)
  4. sanitize(String input)
  5. sanitize(String input)
  6. sanitize(String methodHeader)
  7. sanitize(String mimeType)
  8. sanitize(String original)
  9. sanitize(String path)