这个链接 - http://en.wikipedia.org/wiki/Help:Wiki_markup#Text_formatting%20first%20point - 表示每当一个用粗体或斜体显示文本时,它都包含在2个撇号中,用于''三个撇号中的'''''''''''''''''''''''''''''''''''''撇号'''''粗体斜体''''',我希望能够接受一个String,它具有这种格式作为输入作为函数的输入,并从字符串中删除这种标记以返回清洁文本,我应该用什么样的正则表达式来编写java来实现这一点,我是regexes的新手并且对此没有任何线索。样本内容 -
输入
将他列为500强单打选手中的''''''''''
输出
将他列为500强单打选手中的第89位
答案 0 :(得分:0)
您可以使用以下正则表达式快速替换2-3个撇号组:
[']{2,3}
搜索该模式并替换为空。这应该有效,因为你没有尝试提取匹配。
答案 1 :(得分:0)
尝试,replaceAll()
String sample = "ranked him #'''89''' of the top 500 singles wrestlers";
System.out.println(""+sample.replaceAll("'", ""));
输出:
ranked him #89 of the top 500 singles wrestlers