Java String Sanitize sanitizeForSemgrexName(String text)

Here you can find the source of sanitizeForSemgrexName(String text)

Description

Sanitizes the given string into a Semgrex friendly name

License

Open Source License

Declaration

public static String sanitizeForSemgrexName(String text) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w ww  . j  a  va  2  s . c  o  m*/
     * Sanitizes the given string into a Semgrex friendly name
     */
    public static String sanitizeForSemgrexName(String text) {
        text = text.replaceAll("\\.", "_DOT_");
        text = text.replaceAll("\\,", "_COMMA_");
        text = text.replaceAll("\\\\", "_BSLASH_");
        text = text.replaceAll("\\/", "_BSLASH_");
        text = text.replaceAll("\\?", "_QUES_");
        text = text.replaceAll("\\!", "_BANG_");
        text = text.replaceAll("\\$", "_DOL_");
        text = text.replaceAll("\\!", "_BANG_");
        text = text.replaceAll("\\&", "_AMP_");
        text = text.replaceAll("\\:", "_COL_");
        text = text.replaceAll("\\;", "_SCOL_");
        text = text.replaceAll("\\#", "_PND_");
        text = text.replaceAll("\\@", "_AND_");
        text = text.replaceAll("\\%", "_PER_");
        text = text.replaceAll("\\(", "_LRB_");
        text = text.replaceAll("\\)", "_RRB_");
        return text;
    }
}

Related

  1. sanitizeForCmisName(String in)
  2. sanitizeForCsv(String str)
  3. sanitizeForJson(String data)
  4. sanitizeForLogMessage(String unsanitizedString)
  5. sanitizeForSearch(String str)
  6. sanitizeForTableName(String input)
  7. sanitizeForUri(String uri, String replace)
  8. sanitizeFullPrefixKey(String propKey)
  9. sanitizeGoogleId(String rawGoogleId)