Java String Quote quoteReplacement(String s)

Here you can find the source of quoteReplacement(String s)

Description

quote Replacement

License

Open Source License

Declaration

private static String quoteReplacement(String s) 

Method Source Code

//package com.java2s;

public class Main {
    private static String quoteReplacement(String s) {
        if ((s.indexOf('\\') == -1) && (s.indexOf('$') == -1))
            return s;
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '\\') {
                sb.append('\\');
                sb.append('\\');
            } else if (c == '$') {
                sb.append('\\');
                sb.append('$');
            } else {
                sb.append(c);//from  ww w. j a va  2  s .  c o  m
            }
        }
        return sb.toString();
    }
}

Related

  1. quoteRegexMeta(final String input)
  2. quoteRegexMeta(String str)
  3. quoteRemarkSQL(String sql)
  4. quoteRemarkSQL(String sql)
  5. quoteReplacement(String s)
  6. quotes(CharSequence stringToQuote)
  7. quotes(CharSequence stringToQuote, boolean escapeQuote)
  8. quotes(String str)
  9. quotesEscape(String text)