String s = "...."; Matcher m = Pattern.compile("(; Secure)$").matcher(s); String news = m.replaceAll("");
不是要编程,是要通过正则表达式配置Apache 有人知道,正则表达式要怎么写?
^.+(?=; Secure$)|^.+(?!; Secure$)
试写了下. String str1="Class Object is the root of the class hierarchy.; Secure "; String str2="Every class has Object as a superclass.; Secure All objects, including arrays, implement the methods of this class.cure "; String regex="(.+)(?:; Secure )$"; Pattern p=Pattern.compile(regex); str2=str1; Matcher m=p.matcher(str2); if(m.matches()){ System.out.println(m.group(1)); }else{ System.out.println(str2); }
String s = "....";
Matcher m = Pattern.compile("(; Secure)$").matcher(s);
String news = m.replaceAll("");
有人知道,正则表达式要怎么写?
String str2="Every class has Object as a superclass.; Secure All objects, including arrays, implement the methods of this class.cure ";
String regex="(.+)(?:; Secure )$";
Pattern p=Pattern.compile(regex);
str2=str1;
Matcher m=p.matcher(str2);
if(m.matches()){
System.out.println(m.group(1));
}else{
System.out.println(str2);
}