62,621
社区成员
发帖
与我相关
我的任务
分享 String s1 = "<a href=\"http://www.abc.com\">这个有值 <br /> </a> <a href=\"http://www.aaa.com\"> </a> <a href=\"http://www.aaa.com\"> </a> <a href=\"http://www.aaa.com\"> </a>";
Pattern p = Pattern.compile("(<a .+?>(.+?)</a>)");
Matcher m = p.matcher(s1);
while(m.find()){
String tmp = m.group(2).trim();
if(tmp.length() == 0){
continue;
}
else if(tmp.startsWith(" ")){
continue;
}
System.out.println(m.group(1));
}
String s = "aspnet开发,国内旅游,景点a,123,aspnet开发,提供,景点a,123";
Set<String> set = new HashSet<String>();
int i = 0;
int j = s.indexOf(",");
j = j ==-1 ? s.length() -1 : j;
do{
String tmp = s.substring(i, j).trim();
set.add(tmp);
i = j +1;
j = s.indexOf(",",i);
}while(i<j);
for(String t : set){
System.out.println(t);
}
String sampleStr = "aspnet开发,国内旅游,景点a,123,aspnet开发,提供,景点a,123";
String [] tempStr = sampleStr.spilt(",");
StringBuilder result = new StringBuilder();
for (int i = 0 ; i <= tempStr.length; i ++) {
for (int j = i ; i <= tempStr.length; j++ ){
if (!tempStr[i].equal(tempStr[j])) {
result.append(tempStr[i]);
result.append(",");
}
}
}