Here you can find the source of castForRegex(String textContent)
public static String castForRegex(String textContent)
//package com.java2s; //License from project: Apache License public class Main { public static String castForRegex(String textContent) { return textContent.replace("\\", "\\\\").replace("/", "\\/").replace("*", "\\*").replace("+", "\\+") .replace(".", "\\.").replace("?", "\\?").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}") .replace("(", "\\(").replace("[", "\\[").replace("]", "\\]").replace("%", "\\%"); }//from www.j a v a 2s .c o m }