JSP Tutorial Get the external connection and replace the specified Chinese function
intercept http://Address
Intercepting URLs
Pattern pattern = Pattern.compile ("(Http://|https Tutorial://) {1}[\w\.\-/:]+");
Matcher Matcher = Pattern.matcher ("dsdsdsStringBuffer buffer = new StringBuffer ();
while (Matcher.find ()) {
Buffer.append (Matcher.group ());
Buffer.append ("RN");
System.out.println (Buffer.tostring ());
}
Replace text in specified {}
String str = "Java current phylogeny is by {0} years-{1}";
String[][] object={new string[]{"\{0\}", "1995"},new string[]{"\{1\}", "2007"}};
System.out.println (replace (str,object));
public static string replace (final string sourcestring,object[] object) {
String temp=sourcestring;
for (int i=0;i<object.length;i++) {
String[] result= (string[]) object[i];
Pattern pattern = pattern.compile (result[0]);
Matcher matcher = pattern.matcher (temp);
Temp=matcher.replaceall (result[1]);
}
return temp;
}