import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(\\b)(https?:\\/\\/)(www.)?[\\w-]{2,}\\.[a-zA-Z\\-0-9]{1,}[\\w\\/\\.\\?\\=\\&\\#\\-\\%\\+]*(\\b)";
final String string = "http://127.0.0.1/openserver/phpmyadmin/sql.php?db=projectx&table=messages&sql_query=SELECT+%2A+FROM+%60messages%60&message_to_show=%D0%97%D0%B0%D0%BF%D0%B8%D1%81%D1%8C+%D0%B1%D1%8B%D0%BB%D0%B0+%D1%83%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0&goto=tbl_sql.php&token=81b4b5c88dae1706231d6cd2ab925edb&message=%D0%A3%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0+1+%D1%81%D1%82%D1%80%D0%BE%D0%BA%D0%B0.+%28%D0%97%D0%B0%D0%BF%D1%80%D0%BE%D1%81+%D0%B7%D0%B0%D0%BD%D1%8F%D0%BB+0.1904+%D1%81%D0%B5%D0%BA.%29 \n"
+ "sd fs ";
final String subst = "";
final Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html