从RSS获取一些数据后,在android设备上显示,
这些字符串有些在开始有括号,括号中有一些标示符:
This is a title of something...
[Brochures] This is a brochure title
[Thought Leadership] This is something else
我想把这些括号中的内容都移除,然后再显示在屏幕上。但是不知道应该怎么实现,我想可能用到正则表达式,请高手赐教,谢谢。
System.out.println("[Brochures] This is a brochure title".replaceAll("\\[.*?\\]", ""));
一试便知!
String.replaceAll("\\[[^\\]]*\\]","");
string.replaceAll("\\[.*?\\]","");