public class Regex1 {
public static void main(String[] args) {
String s = "神秘的海洋出现了一只#话题#海怪阿拉斯加#热门话题#和一艘很诡异的破船\n";
System.out.println("例子:"+s);
Pattern pattern = Pattern.compile("#(.*?)#");
Matcher matcher = pattern.matcher(s);
while (matcher.find()){
System.out.println(matcher.group(1));
}
System.out.println(s.replaceAll("#(.*?)#",""));
}
}
posted on 2018-05-31 15:36  背起全世界の蜗牛  阅读(1615)  评论(0编辑  收藏  举报